private IEnumerator SpawnAllEnemiesInWave(WaveConfig wave) { int numberOfEnemies = wave.GetNumberOfenemies(); for (int index = 0; index < numberOfEnemies; index++) { var newEnemy = Instantiate(wave.GetEnemyPrefab(), wave.GetWayPoints()[0].transform.position, Quaternion.identity); newEnemy.GetComponent <EnemyPathing>().setWaveConfig(wave); yield return(new WaitForSeconds(wave.GetTimeBetweenSpawns())); } }