IEnumerator SpawnAllWaves() { for (int waveIndex = startingWave; waveIndex < waveConfigs.Count; waveIndex++) { WaveConfig currentWave = waveConfigs[waveIndex]; if (FindObjectOfType <Player>() == null || FindObjectOfType <Player>().destroyed) { StopAllCoroutines(); Destroy(gameObject); } if (currentWave.GetSkipDelay()) { StartCoroutine(SpawnWave(currentWave)); yield return(null); } else { yield return(StartCoroutine(SpawnWave(currentWave))); yield return(StartCoroutine(Timer.Delay(currentWave.GetDelay() * currentWave.GetMovespeed()))); } } }