private IEnumerator UFOSpawnRoutine() { //While the Classic Round Logic allocated ufo count is not 0 while (currentUFOCount > 0) { //Get a random integer between 0 and count to indicate if this frame a UFO will spawn int randomUFOSpawn = Random.Range(0, currentUFOCount); //If the random integer is GT 0 and the allocated ufo count is GT 0 if (randomUFOSpawn > 0 && currentUFOCount > 0) { //Spawn a ufo and decrement the allocated ufo count. ufoSpawner.Spawn(); currentUFOCount--; } //If there is LT 3 asteroids, spawn all remaining UFOs if (asteroidSpawner.getActiveCount() < 3 && currentUFOCount > 0) { for (int i = 0; i < currentUFOCount; i++) { ufoSpawner.Spawn(); } currentUFOCount = 0; } //Wait for 3 seconds before trying to spawn again. yield return(new WaitForSeconds(3.0f)); } //Just return if the allocated ufo count is 0. yield return(null); }
private IEnumerator UFOSpawnRoutine() { while (currentUFOCount > 0) { int randomUFOSpawn = Random.Range(0, currentUFOCount + 1); if (randomUFOSpawn > 0 && currentUFOCount > 0) { ufoSpawner.Spawn(); currentUFOCount--; } yield return(new WaitForSeconds(3.0f)); } yield return(null); }