Example #1
0
 private void StopSpawning(int enemies)
 {
     if (_coroutine != null)
     {
         StopCoroutine(_coroutine);
         WaveEnded?.Invoke();
     }
 }
Example #2
0
 private IEnumerator SpawnEnemies(List <GameObject> enemies)
 {
     foreach (var enemy in enemies)
     {
         SpawnEnemy(enemy);
         yield return(new WaitForSeconds(1f));
     }
     WaveEnded?.Invoke();
 }
Example #3
0
    private void OnZombiDied(Zombi zombi)
    {
        zombi.Died -= OnZombiDied;

        _waveSize--;

        if (_waveSize == 0 && _currentWaveIndex >= _waves.Count)
        {
            GameWon?.Invoke();
        }
        else if (_waveSize == 0)
        {
            WaveEnded?.Invoke();
        }
    }
Example #4
0
        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();
            }
        }