Example #1
0
    private EnemyWave.SubWave PrepareSubWave()
    {
        if (currentSubWaveIndex < 0)
        {
            currentSubWaveIndex = 0;
        }

        // `subWave` should never be `null`, as `currentSubWaveIndex` should always reflect the current, valid sub-wave
        EnemyWave.SubWave subWave = waves[currentWaveIndex].GetSubWave(currentSubWaveIndex);
        if (subWave.IsPause)
        {
            // If the current sub-wave is a pause sub-wave, that means it's already over,
            // so return the next one (if it exists)
            return(GoToNextSubWave(currentWaveIndex));
        }

        if (currentSubWaveEnemyCounter < subWave.number)
        {
            // Can continue with sub-wave, so return it
            return(subWave);
        }
        else
        {
            // Sub-wave is over, so return the next one (if it exists)
            return(GoToNextSubWave(currentWaveIndex));
        }
    }
Example #2
0
    private EnemyWave.SubWave GoToNextSubWave(int waveIndex)
    {
        // Check next sub-wave:
        EnemyWave.SubWave subWave = waves[waveIndex].GetSubWave(currentSubWaveIndex + 1);
        if (subWave != null)
        {
            // Update sub-wave index and reset enemy counter
            currentSubWaveIndex++;
            currentSubWaveEnemyCounter = 0;
        }

        return(subWave);
    }
Example #3
0
    private void SpawnNextEnemy()
    {
        EnemyWave.SubWave subWave = PrepareSubWave();
        if (subWave == null)
        {
            // Reached the end of the sub-wave(s), and therefore also the current wave
            hasWaveEnded = true;
            return;
        }

        if (subWave.IsPause)
        {
            timeUntilNextSpawn = subWave.pauseDuration;
            return;
        }

        enemyManager.SpawnEnemy(subWave.enemyType);
        currentSubWaveEnemyCounter++;
    }