private IEnumerator AsteroidWaveControllerCoroutine() { var spawner = FindObjectOfType <AsteroidSpawner>(); while (true) { // 1 sec for preparation if (OnPrepareStarted != null) { OnPrepareStarted.Invoke(); } yield return(new WaitForSeconds(1f)); // START if (OnWaveStarted != null) { OnWaveStarted.Invoke(CurrentWaveNumber); } spawner.AsteroidTypeLevel = CurrentWaveNumber; spawner.Spawning = true; yield return(new WaitForSeconds(_waveDuration)); spawner.Spawning = false; yield return(new WaitForSeconds(_cooldownDuration)); CurrentWaveNumber++; if (OnBreakStarted != null) { OnBreakStarted.Invoke(CurrentWaveNumber); } yield return(new WaitForSeconds(_breakDuration)); _asteroidSpawner.IncreaseAsteroidsSpeed(); } }