private void HandleNextWaveSpawn()
 {
     if (_currentWave >= levelDetailsScriptableObject.waves.Length)
     {
         AllWavesComplete?.Invoke(this, EventArgs.Empty);
     }
     else
     {
         WaveComplete?.Invoke(this, new WaveClearedEvent {
             ClearedWave = _currentWave
         });
         SpawnWave();
     }
 }
Example #2
0
        void OnWaveComplete()
        {
            var completedWave = waves[currentWave];

            completedWave.WaveComplete     -= OnWaveComplete;
            completedWave.EnemyReachedBase -= OnEnemyReachedBase;
            completedWave.EnemyKilled      -= OnEnemyKilled;

            WaveComplete?.Invoke(completedWave);

            if (waves.TrueForAll(x => x.WaveCompleted))
            {
                Log.Info("All Waves Complete!");
                AllWavesComplete?.Invoke();
            }
            else
            {
                delayTimer = new Timer(delayBetweenWaves, () => MoveToNextWave());
            }
        }