public static void StartALevel() { Debug.Log("StartALevel called for " + CurrentLevel.gameObject.name); //check that Lobby Level is currently running, if so transition to a new Level if (CurrentLevel == Level.LobbyLevel) { Level newToLoad = (_levels.ContainsKey(PlayerUser.LastLevelCompleted + 1)) ? _levels[PlayerUser.LastLevelCompleted + 1] : Level.LobbyLevel; //fallback is lobby level UnitMgr.ClearUnitsData(); Level.LobbyLevel.gameObject.SetActive(false); CurrentLevel = newToLoad; newToLoad.gameObject.SetActive(true); //TODO: at some point make a fancier scheme for difficulty selection so that holes greater or less than town count! newToLoad.Reset(PlayerUser.LastLevelCompleted + 1, PlayerUser.LastLevelCompleted + 1); PlayerUser.ResetPlayerPosition(); PlayerUser.ResetLevelStartingResources(); UnitMgr.ResetWaveLogic(); string text = $"Current Level Obtained: {PlayerUser.LastLevelCompleted + 1}"; DisplayInfoDesktop.SetDisplayInfo(text); } else { Debug.LogWarning("LevelMgr.StartALevel() called from outside the Lobby!"); } MenuInGameObject?.GetComponent <MenuInGame>()?.UpdateNow(); StatusInGameComponent?.Show(true); if (CurrentLevel == Level.LobbyLevel) //if new level not found and the lobby reloaded { StatusInGameComponent?.SetAlert("Level " + (PlayerUser.LastLevelCompleted + 1) + " not found, back to Lobby", Color.red); } else { StatusInGameComponent?.SetAlert("Level " + (PlayerUser.LastLevelCompleted + 1) + " Loaded", Color.white); } }
public static void BackToLobby() { Debug.Log("BackToLobby called!"); //TODO: ensure PlayerUser stats updated before this was called (i.e. progress saved) MenuInGameObject?.GetComponent <MenuInGame>()?.UpdateNow(); MenuInGameObject?.GetComponent <MenuInGame>().Show(false); //_statusInGameComponent?.Show(false); if (CurrentLevel != Level.LobbyLevel) { CurrentLevel.CleanUp(); CurrentLevel.gameObject.SetActive(false); CurrentLevel = Level.LobbyLevel; Level.LobbyLevel.gameObject.SetActive(true); PlayerUser.ResetPlayerPosition(); } else { Debug.LogWarning("LevelMgr.BackToLobby() called from the Lobby!"); } DisplayInfoDesktop.SetDisplayInfo(""); }