Example #1
0
    // Main clock that iterates through the waves
    private IEnumerator WaveClockCoroutine()
    {
        for (int i = 0; i < Waves.Length; i++)
        {
            if (gm.Paused)
            {
                yield return(new WaitForSeconds(0.1f));

                i--;
                continue;
            }
            waveText.ShowText((i == Waves.Length - 1) ? "Last Wave" : $"Wave {i + 1}");
            waveCounter.ShowWaves();
            waveCounter.IncrementWave();

            // Wait for alloted amount of time
            float timeElapsed = 0f;

            while (timeElapsed <= WaveCooldown / gm.GameSpeed)
            {
                if (!gm.Paused)
                {
                    timeElapsed += GameManager.TimeStep;
                }
                yield return(new WaitForSeconds(GameManager.TimeStep));
            }

            yield return(StartCoroutine(SpawnWaveCoroutine(i)));

            yield return(StartCoroutine(WaitForLastEnemy()));
        }

        yield return(StartCoroutine(WaitForLastEnemy()));

        EndAssault();
    }