private IEnumerator SpawnAllEnemiesInWave(WaveConfig waveConfig) { for (int enemyCount = 0; enemyCount < waveConfig.GetNumberOfEnemy(); enemyCount++) { var NewEnemy = Instantiate(waveConfig.GetEnemyPrefab(), waveConfig.GetWaypoints()[0].transform.position, Quaternion.identity); NewEnemy.GetComponent <EnemyPathing>().SetWaveConfig(waveConfig); yield return(new WaitForSeconds(waveConfig.GetTimeBetweenSpawns())); } }
IEnumerator SpawnEnemy() { for (float num = 0; num < waveConfig.GetNumberOfEnemy(); num++) { var spawnEnemy = Instantiate( waveConfig.GetEnemyPrefab(), waveConfig.GetWaypoint()[0].transform.position, Quaternion.identity); spawnEnemy.GetComponent <EnemyPath>().SetWaveConfig(waveConfig); } yield return(new WaitForSeconds(waveConfig.GetTimeBetweenSpawn())); }
//1Wave中ですべての敵をSpawn //この関数は単に指定した回数、指定したObjectのInstanceを作成するだけである。 //Insatanceのその後の挙動には全くタッチしないのでInstanceの挙動自体はEnemyPathスクリプトが行う。 private IEnumerator SpawnAllEnemiesInWave(WaveConfig waveConfig) { //waveconfigで設定した敵の数の回数文だけForループを回す for (int enemyCount = 0; enemyCount < waveConfig.GetNumberOfEnemy(); enemyCount++) { var newEnemy = Instantiate( waveConfig.GetEnemyPrefab(), waveConfig.GetWaypoints()[0].transform.position, Quaternion.identity); newEnemy.GetComponent <EnemyPath>().SetWaveConfig(waveConfig); yield return(new WaitForSeconds(waveConfig.GetTBSpawn())); } }
/// <summary> /// Spawn the specefic waveconfig to perform enemy movement /// </summary> /// <param name="wave">The waveconfig thats need to be followed to move an enemy.</param> /// <returns></returns> private IEnumerator SpawnEnemy(WaveConfig wave) { for (int i = 0; i < wave.GetNumberOfEnemy(); i++) { var newEnemy = Instantiate( wave.GetEnemyPrefab(), wave.GetEnemyWaypoints()[0].transform.position, Quaternion.identity); newEnemy.GetComponent <EnemyPathing>().waveConfig = wave; yield return(new WaitForSeconds(wave.GetTimeBetweenSpawns())); } }