protected override void OnUpdate() { if (screenDimensions.x != Screen.width || Screen.height != screenDimensions.y) { screenDimensions.x = Screen.width; screenDimensions.y = Screen.height; //Debug.Log("Screen size has changed: " + screenDimensions.ToString()); //.if (cameraRenders.Count > 0) ResizeRenderTextures(); } Entities.WithAll <SpawnCameraCommand>().ForEach((Entity e, ref SpawnCameraCommand command) => { if (command.isController == 1) { Entity camera = SpawnCamera(command.id, command.position, command.rotation, command.attachEntity, command.data); World.EntityManager.AddComponentData(camera, command.controller); //Debug.LogError("Adding New Controller: " + command.id); MenuSpawnSystem.SpawnUI(EntityManager, camera, "MainMenu"); EntityManager.DestroyEntity(playerSystem.controllers[command.id]); playerSystem.controllers.Remove(command.id); playerSystem.controllers.Add(command.id, camera); // adds with device id } World.EntityManager.DestroyEntity(e); }); Entities.WithAll <RemoveCameraCommand>().ForEach((Entity e, ref RemoveCameraCommand command) => { //RemoveUI(command.character); World.EntityManager.DestroyEntity(e); }); }
public void AddGameUI(Entity character, int gameUIIndex) { //UnityEngine.Debug.LogError("(Queueing) Spawning " + gameUIIndex + " on character: " + character.Index); if (gameUIIndex == ((byte)PlayerUIType.StatsUI)) { // UnityEngine.Debug.LogError("(Queueing) [StatsUI] Spawning " + gameUIIndex + " on character: " + character.Index); StatsUISpawnSystem.SpawnUI(World.EntityManager, character); } else if (gameUIIndex == ((byte)PlayerUIType.InventoryUI)) { // UnityEngine.Debug.LogError("(Queueing) [InventoryUI] Spawning " + gameUIIndex + " on character: " + character.Index); InventoryUISpawnSystem.SpawnUI(World.EntityManager, character); } else if (gameUIIndex == ((byte)PlayerUIType.QuestlogUI)) { // UnityEngine.Debug.LogError("(Queueing) [QuestlogUI] Spawning " + gameUIIndex + " on character: " + character.Index); QuestLogUISpawnSystem.SpawnUI(World.EntityManager, character); } //else if (gameUIIndex == ((byte)PlayerUIType.DialogueUI)) //{ // UnityEngine.Debug.LogError("(Queueing) [DialogueUI] Spawning " + gameUIIndex + " on character: " + character.Index); //DialogueUISpawnSystem.SpawnUI(World.EntityManager, character); //} else if (gameUIIndex == ((byte)PlayerUIType.MapUI)) { // UnityEngine.Debug.LogError("(Queueing) [MapUI] Spawning " + gameUIIndex + " on character: " + character.Index); MapUISpawnSystem.SpawnUI(World.EntityManager, character); } else if (gameUIIndex == ((byte)PlayerUIType.SkillbookUI)) { //UnityEngine.Debug.LogError("(Queueing) [SkillbookUI] Spawning " + gameUIIndex + " on character: " + character.Index); SkillbookUISpawnSystem.SpawnUI(World.EntityManager, character); } else if (gameUIIndex == ((byte)PlayerUIType.EquipmentUI)) { EquipmentUISpawnSystem.SpawnUI(World.EntityManager, character); } else if (gameUIIndex == ((byte)PlayerUIType.Menu)) { MenuSpawnSystem.SpawnUI(World.EntityManager, character, "PauseMenu"); } }
private void OnStateChanged(Entity world, int metaID, GameState oldState, GameState newState) { Debug.Log("New Game state: " + newState); if (oldState == GameState.StartScreen && newState == GameState.MainMenu) { OnStarted.Invoke(); } if (newState == GameState.MainMenu) { OnStarted.Invoke(); //Debug.LogError("Game starting with: " + playerSpawnSystem.controllers.Count + " Players."); foreach (KeyValuePair <int, Entity> KVP in playerSpawnSystem.controllers) { if (World.EntityManager.Exists(KVP.Value)) { CameraSystem.SpawnCameraController(World.EntityManager, meta[metaID].startingCamera.Value, EntityManager.GetComponentData <Controller>(KVP.Value), KVP.Key); } } } //int cameraID = cameraSystem.SpawnCamera(meta[metaID].startingCamera.Value); //Entity camera = cameraSystem.cameras[cameraID]; // systemsManager.cameraSystem.cam //EntityManager.AddComponentData(camera, EntityManager.GetComponentData<Controller>(KVP.Value)); //newEntites.Add(KVP.Key, camera); /*try * { * worldSpawnSystem.OnAddedStreamer(camera, worldID); * } * catch (System.Exception e) * { * Debug.LogError(e.ToString()); * }*/ /*else if (newState == GameState.NewGameScreen) * { * Debug.LogError("Spawn New Game UI for players (they should both be able to edit new game data)"); * //mainScreen.DeinitializeIt(); * // spawn a character * // remove its controller * // move camera to new character * //newGameScreen.InitializeIt(); * // edit colours of character model * // spawn a character to edit * }*/ else if (newState == GameState.PauseScreen) { foreach (Entity entity in playerSpawnSystem.controllers.Values) { //Controller controller = EntityManager.GetComponentData<Controller>(entity); MenuSpawnSystem.SpawnUI(World.EntityManager, entity, "PauseMenu"); //systemsManager.menuSpawnSystem.QueueSpawnUI(entity, "PauseMenu"); } } else if (newState == GameState.GameUI) { foreach (Entity entity in playerSpawnSystem.controllers.Values) { Controller controller = EntityManager.GetComponentData <Controller>(entity); gameUISystem.AddGameUI(entity, controller.gameUIIndex); // spawn the game ui } } else if (newState == GameState.InGame) { menuSpawnSystem.Clear(); gameUISystem.Clear(); //pauseScreen.DeinitializeIt(); } else if (newState == GameState.RespawnScreen) { //Debug.LogError("TODO: Spawn Player Respawn UI"); // detatch camera from character // add in dead post processing effects //systemsManager.menuSpawnSystem.QueueSpawnUI(entity, "Respawn"); //endOfGameScreen.InitializeIt(); } }