Exemplo n.º 1
0
        public void Advance()
        {
            if (_currentWaveIndex >= _spawnWaves.Count)
            {
                return;
            }

            Debug.Log("Advancing NPC wave spawner...");

            // stop the current wave timers
            if (_currentWaveIndex >= 0)
            {
                CurrentWave.Stop();

                WaveCompleteEvent?.Invoke(this, new SpawnWaveEventArgs(_currentWaveIndex, _currentWaveIndex >= _spawnWaves.Count - 1));
            }

            // advance the wave
            _currentWaveIndex++;
            if (_currentWaveIndex >= _spawnWaves.Count)
            {
                return;
            }

            // start the next wave of timers
            CurrentWave.Start();

            WaveStartEvent?.Invoke(this, new SpawnWaveEventArgs(_currentWaveIndex, _currentWaveIndex >= _spawnWaves.Count - 1));
        }
Exemplo n.º 2
0
        private void Run()
        {
            if (_currentWaveIndex >= _spawnWaves.Count)
            {
                return;
            }

            // stop the current wave timers
            if (_currentWaveIndex >= 0)
            {
                CurrentWave.Stop();
                WaveCompleteEvent?.Invoke(this, new SpawnWaveEventArgs(_currentWaveIndex, _currentWaveIndex >= _spawnWaves.Count - 1));
            }

            // advance the wave
            _currentWaveIndex++;
            if (_currentWaveIndex >= _spawnWaves.Count)
            {
                return;
            }

            // start the next wave of timers
            CurrentWave.Start();
            _waveTimer.Start(CurrentWave.Duration);

            WaveStartEvent?.Invoke(this, new SpawnWaveEventArgs(_currentWaveIndex, _currentWaveIndex >= _spawnWaves.Count - 1));
        }
 void StartWave()
 {
     //check for remaining waves
     if (cur_wave_index >= wave_list.Count)
     {
         Debug.Log("StartWave() fail @ index");
     }
     //check for wave in progress
     else if (flag_wave_in_progress)
     {
         Debug.Log("StartWave() fail @ flag");
     }
     else
     {
         Debug.Log("Wave manager: starting wave");
         flag_wave_in_progress = true; //I'll bet its safer to leave this here
         WaveStartEvent?.Invoke(this, System.EventArgs.Empty);
         StartCoroutine(ContinueWave(wave_list[cur_wave_index]));
     }
 }
Exemplo n.º 4
0
    private void Update()
    {
        GameObject[] list = GameObject.FindGameObjectsWithTag("Enemy");

        if (list.Length <= 0)
        {
            if (timer <= 0)
            {
                waveN++;
                timer = wavePause;
                for (int i = 0; i < Mathf.RoundToInt(waveCount); i++)
                {
                    Spawn();
                }
                WaveStartEvent.Invoke(waveN, Mathf.RoundToInt(waveCount));
                waveCount = waveCount * waveMod;
            }
            else
            {
                timer -= Time.deltaTime;
            }
        }
    }