IEnumerator PlayLevel() { do { if (failed && currentLevel != 7) { uiController.FailedLevel(); yield return(new WaitForSeconds(3)); uiController.ClearFail(); } else { yield return(new WaitForSeconds(3)); } uiController.StartLevel(currentLevel); if (currentLevel != 7) { yield return(new WaitForSeconds(3)); uiController.HideGameUI(currentLevel); } else { yield return(new WaitForSeconds(3)); } if (currentLevel >= 2 && BaseDrop.volume == 0) { StartCoroutine(DropBase()); } if (failed) { yield return(new WaitForSeconds(2f)); } failed = false; resetOnFail = false; Spawner.StartSpawning(); int i = 0; while (i < 40) { yield return(new WaitForSeconds(.5f)); i++; if (failed) { break; } } if (failed) { continue; } Spawner.StopAsteroids(); if (currentLevel != 7) { i = 0; while (i < 10) { yield return(new WaitForSeconds(.5f)); i++; if (failed) { break; } } if (failed) { continue; } Spawner.StopMines(); i = 0; while (i < 6) { yield return(new WaitForSeconds(.5f)); if (failed) { break; } i++; } if (failed) { continue; } Spawner.SpawnGate(GateScale[currentLevel]); } i = 0; while (!CheckWinCondition(currentLevel, Player) && !failed) { yield return(new WaitForSeconds(.1f)); i++; } } while (failed); Spawner.TriggerVictoryOnGate(); uiController.Success(); yield return(new WaitForSeconds(3f)); Player.resetToNextLevel(); // Level Victory currentLevel++; uiController.HideSuccess(); if (currentLevel < GateScale.Count) { StartCoroutine(PlayLevel()); } else { uiController.ShowCredits(); Spawner.StartSpawning(); } }