private IEnumerator SpawnEnemyWave(Waveconfig wave) { for (int i = 0; i < wave.GetNumberOfEnemies(); i++) { Instantiate( wave.GetEnemy(), transform.position, Quaternion.identity); yield return(new WaitForSeconds(wave.GetSpawnTime())); } yield return(new WaitForSeconds(wave.GetSpawnDuration())); }
private IEnumerator SpawnAllEnemiesInWave(Waveconfig waveConfig) { for (int index = 0; index < waveConfig.GetNumberOfEnemies(); index++) { var newEnemy = Instantiate( waveConfig.GetEnemyPrefab(), waveConfig.GetWaypoints()[0].transform.position, Quaternion.identity); newEnemy.GetComponent <Enemy>().SetWaveConfig(waveConfig); yield return(new WaitForSeconds(waveConfig.GetTimeBetweenSpawns())); } }