Esempio n. 1
0
    private void Update()
    {
        if (_currentWave == null)
        {
            return;
        }

        _timeAfterLastSpawn += Time.deltaTime;

        if (_timeAfterLastSpawn >= _currentWave.Delay)
        {
            InstantiateEnemy();
            _spawned++;
            EnemySpawnChanged?.Invoke(_spawned, _currentWave.Count);
            _timeAfterLastSpawn = 0;
        }

        if (_currentWave.Count <= _spawned)
        {
            if (_waves.Count > _currentWaveNumber + 1)
            {
                AllEnemySpawned?.Invoke();
            }

            _currentWave = null;
        }
    }
Esempio n. 2
0
 public void NextWave()
 {
     EnemySpawnChanged?.Invoke(0, 1);
     SetWave(++_currentWaveNumber);
     _spawned = 0;
 }
Esempio n. 3
0
 private void Start()
 {
     SetWave(_currentWaveNumber);
     EnemySpawnChanged?.Invoke(0, 1);
 }