public void DoSpawning() { if (!HasCompletedWave()) { EnemyWave wave = waves[currentWave]; if (!wave.IsCompleted()) { EnemyWaveEntry entry = wave.CurrentSetToSpawn(); bool spawnedUnits = false; //Spot trying to spawn if we spawn something or are out of things to spawn while (!spawnedUnits && !wave.IsCompleted()) { if (entry == null || entry.numberSpawnedSoFar >= entry.numberToSpawn) { wave.InitNext(); } else { SpawnUnit(entry.prefabToSpawn); entry.numberSpawnedSoFar++; } } } else { Debug.Log("EnemySpawner: Done with wave " + currentWave); doneWithWave = true; } } }