private void StopSpawning(int enemies) { if (_coroutine != null) { StopCoroutine(_coroutine); WaveEnded?.Invoke(); } }
private IEnumerator SpawnEnemies(List <GameObject> enemies) { foreach (var enemy in enemies) { SpawnEnemy(enemy); yield return(new WaitForSeconds(1f)); } WaveEnded?.Invoke(); }
private void OnZombiDied(Zombi zombi) { zombi.Died -= OnZombiDied; _waveSize--; if (_waveSize == 0 && _currentWaveIndex >= _waves.Count) { GameWon?.Invoke(); } else if (_waveSize == 0) { WaveEnded?.Invoke(); } }
protected virtual void OnWaveEnded(Wave wave) { wave.HasEnded -= OnWaveEnded; _ActiveWaves.Remove(wave); _CompletedWaves.Add(wave); bool isLastWave = _WaitingWaves.Count <= 0; WaveEventArgs payload = new WaveEventArgs(wave, isLastWave); WaveEnded?.Invoke(this, payload); if (isLastWave) { _State = EState.INACTIVE; } else { StartIntermission(); } }