IEnumerator spawnEnemies() { isSpawning = true; List <EnemyEnum> waveArray = waves[GameManager.currentWave % 24].getAsList(); int healthMultiplier = 2 * (GameManager.currentWave / numDistinctWaves) + 1; EnemyPrefabs enemyPrefabsInstance = EnemyPrefabs.instance; for (int i = 0; i < waveArray.Count; i++) { GameObject enemy = (GameObject)Instantiate(enemyPrefabsInstance.getEnemyPrefabFromType(waveArray[i]), spawnLocation.position, spawnLocation.rotation); BaseHealth healthComponent = enemy.GetComponent <BaseHealth>(); if (healthComponent != null && healthMultiplier > 1) { healthComponent.multiplyHealth(healthMultiplier); } yield return(new WaitForSeconds(intrawaveCountdown)); } isSpawning = false; }