package gameEngine.scenes; import gameEngine.GameEditor; import gameEngine.entites.Entity; import gameEngine.entites.GameObject; import gameEngine.entites.gameComponents.ColorController; import gameEngine.entites.gameComponents.GameComponent; import gameEngine.entites.gameComponents.Mesh; import gameEngine.entites.gameComponents.MoveImage; import gameEngine.input.*; import gameEngine.views.Color; import gameEngine.views.Window; import java.awt.event.KeyEvent; import java.util.HashMap; import static org.lwjgl.opengl.GL11.glClearColor; public class EditorScene extends Scene { private boolean isCreateObject = false; private boolean isAddComponent = false; private boolean isRemoveComponent = false; private GameObject addComponentObject; private GameObject removeComponentObject; private GameComponent removeComponent; public EditorScene(){ this.entities = entities; System.out.println("Active Editor scene"); glClearColor(1, 1, 1, 0); //GameObjectの追加 entities.put(0, new GameObject(0)); GameObject g0 = (GameObject) entities.get(0); g0.addComponent(new ColorController()); g0.setName("ColorController"); } public EditorScene(HashMap<Integer, Entity> entities){ this.entities = entities; System.out.println("Active Editor scene"); glClearColor(1, 1, 1, 0); } @Override public void update(float dt) { changeScene(1, dt); //Gameシーンへの以降処理 if(isCreateObject){ createGameObject(); isCreateObject = false; } if(isAddComponent){ addComponent(); addComponentObject = null; isAddComponent = false; } if(isRemoveComponent){ removeComponent(); removeComponentObject = null; removeComponent = null; isRemoveComponent = false; } } public void createNewObject(){ if(isCreateObject) return; isCreateObject = true; } public void addComponent(GameObject gameObject){ if(isAddComponent) return; addComponentObject = gameObject; isAddComponent = true; } public void removeComponent(GameObject gameObject, GameComponent gameComponent){ if(isRemoveComponent) return; removeComponentObject = gameObject; removeComponent = gameComponent; isRemoveComponent = true; } private void createGameObject(){ int newId = entities.size(); entities.put(newId, new GameObject(newId)); GameObject newGameObject = (GameObject) entities.get(newId); newGameObject.addComponent(new Mesh(entities.get(newId), Mesh.MeshType.SPRITE, "test.png")); newGameObject.setName("NewEntity" + newId); } private void addComponent(){ addComponentObject.addComponent(new MoveImage(addComponentObject)); } private void removeComponent(){ removeComponentObject.removeComponent(removeComponent); } }