public List <Npc> GetCurrentSpawnedNpcs() { var npcs = new List <Npc>(); CurrentSpawnedWaves.ForEach(wave => npcs.AddRange(wave.SpawnedNpcs)); return(npcs); }
private void StartSpawnWave() { if (CurrentWaveCount >= NumberOfWaves) { return; } _waitingForWave = false; CurrentWaveCount += 1; CurrentElapsedTime = WaveCooldown; var wave = GameManager.Instance.WaveGenerator.GenerateWave(CurrentWaveCount); wave.WaveNumber = CurrentWaveCount; CurrentSpawnedWave = wave; CurrentSpawnedWaves.Add(wave); Debug.Log("----- Spawning Wave " + CurrentWaveCount + "-----"); StartCoroutine(SpawnWave(wave)); }
private void Update() { if (!GameManager.Instance.PlayerReady) { return; } if (CurrentWaveCount >= NumberOfWaves && CurrentSpawnedWaves.Count == 0) { GameManager.Instance.WinGame(); } if (CurrentSpawnedWaves.Count == 0 && !_waitingForWave) { _waitingForWave = true; StartCoroutine(WaitForNextWave()); } var wavesToRemove = new List <Wave>(); CurrentSpawnedWaves.ForEach(wave => { if (wave.NpcSpawnCount >= wave.NpcCount && wave.SpawnedNpcs.All(npc => npc == null)) { //give rewards GameManager.Instance.Player.IncreaseAmbassadors(GameSettings.AmbassadorsPerWave); for (int i = 0; i < GameSettings.TowersPerWave; i++) { GameManager.Instance.TowerBuildManager.AddRandomBuildableTower(); } wavesToRemove.Add(wave); } }); CurrentSpawnedWaves = CurrentSpawnedWaves.Except(wavesToRemove).ToList(); }