// should take in playerID as well so only player spawns a character public void OnClickedLoadCharacterButton(Entity player, Entity ui, int arrayIndex, ButtonType buttonType) { var playerSlots = saveSystem.GetPlayerSlots(); if (arrayIndex < playerSlots.Length) { var playerToLoad = int.Parse(playerSlots[arrayIndex]); //Debug.LogError("Clicked Character ID:[" + playerToLoad + "]:: with button " + buttonType + " with slots " + playerSlots.Length); // clear menu // open player menu if (buttonType == ButtonType.ButtonA) { Clear(); LoadPlayer(player, playerToLoad, 0); } // todo: add a confirm ui else if (buttonType == ButtonType.ButtonX) { //Debug.LogError("X BUTTON PRESSED2"); Childrens children = World.EntityManager.GetComponentData <Childrens>(ui); children.DestroyEntity(World.EntityManager, arrayIndex); World.EntityManager.SetComponentData(ui, children); saveSystem.DeletePlayer(playerToLoad); var panelUI = World.EntityManager.GetComponentData <GridUI>(ui); panelUI.dirty = 1; World.EntityManager.SetComponentData(ui, panelUI); } } // new else if (arrayIndex == playerSlots.Length) { //Debug.LogError("Spawning new Character."); // start new game //string characterName = saveManager.GetPlayerSlots()[arrayIndex - 1]; //Debug.LogError("Starting New Character!"); // spawn a character randomly in main menu map // zoom into it with camera Clear(); foreach (Entity entity in playerSpawnSystem.controllers.Values) { // spawn new character // camera to zoom next to character SpawnUI(EntityManager, entity, "ClassChoice"); } } else if (arrayIndex == playerSlots.Length + 1) { //Debug.LogError("Returning to prior menu."); //Debug.LogError("Returning to LoadGame."); Clear(); foreach (Entity entity in playerSpawnSystem.controllers.Values) { SpawnUI(EntityManager, entity, "LoadGame"); } } // load character else { Debug.LogError("RANDOM ERROR?A>SDAWAW? " + playerSlots.Length); } }