private void Spawner_OnSpawnTick() { if (UnitMgr.StillRoomToCreateNewUnits(Team)) { _unitSpawnFrameDelay = Random.Range(0, SPAWN_DELAY_MAX_FRAMES_SPREAD); // >-1 value triggers spawn } }
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 void CleanUp() { //reset non-local data lists UnitMgr.ClearUnitsData(); TowerMgr.ClearTowersData(); //reset local data list(s) Spawners = new List <Spawner>(); //Clear level LevelChildDeleteOnReset[] toDelete = GetComponentsInChildren <LevelChildDeleteOnReset>(); if (toDelete != null) { foreach (var t in toDelete) { if (t == null) { continue; } t.gameObject.SetActive(false); Destroy(t.gameObject); } } }