IEnumerator EnemyPathing(WaveConfig waveConfig) { for (int i = 0; i < waveConfig.GetEnemyCount(); i++) { var transforms = waveConfig.GetPaths(); var enemy = Instantiate(waveConfig.GetEnemy(), transforms[0].position, Quaternion.identity); enemy.GetComponent <EnemyPathing>().SetWaveConfig(waveConfig); yield return(new WaitForSeconds(waveConfig.GetBuildTime())); } }
private IEnumerator SpawnAllEnemiesInWave(WaveConfig wc) { GameObject enemyPrefab = wc.GetEnemy(); enemyPrefab.GetComponent <Enemy>() .SetEnemyParams(wc.GetHP(), wc.GetMinFireRate(), wc.GetMaxFireRate(), wc.GetWayPoint(), wc.GetMoveSpeed()); for (int i = 0; i < wc.GetEnemyCount(); i++) { GameObject enemy = Instantiate(enemyPrefab, enemyPrefab.transform.position, Quaternion.identity); yield return(new WaitForSeconds(wc.GetSpawnTime())); } }
private IEnumerator SpawnAllEnemiesInWave(WaveConfig waveConfig) { for (int i = 0; i < waveConfig.GetEnemyCount(); i++) { var spawned = Instantiate( waveConfig.GetEnemy(), waveConfig.GetWaypoints()[0].transform.position, Quaternion.identity ); spawned.GetComponent <EnemyPathing>().SetWaveConfig(waveConfig); yield return(new WaitForSeconds(waveConfig.GetSpawnTime())); } }
private IEnumerator SpawnAllEnemiesInWave(WaveConfig waveConfig, int waveIndex) { yield return(new WaitForSeconds(timestamps[waveIndex] - currentTime)); Debug.Log(WaveConfigs[waveIndex]); for (int i = 0; i <= waveConfig.GetNumOfEnemies(); i++) { GameObject enemy = Instantiate(waveConfig.GetEnemy()); enemy.transform.position = waveConfig.GetStartPos(); enemy.GetComponent <PathMoverSimple>().SetPath(waveConfig.GetPath()); enemy.GetComponent <PathMoverSimple>().setWaypoints(); enemy.GetComponent <PathMoverSimple>().SetSpeed(waveConfig.GetSpeed()); EnemySpawned.Invoke(); yield return(new WaitForSeconds(waveConfig.GetSpawnInterval())); } }