private IEnumerator SetupNextWave(WaveConfig currentWave) { // Don't show indicator on the first wave if (waveNumber == 1) { yield return(new WaitForSeconds(currentWave.GetWaveDelay())); waveNumber++; } else { // Show some feedback to the player waveIndicator.gameObject.SetActive(true); waveIndicator.text = $"Level {waveNumber++}"; yield return(new WaitForSeconds(currentWave.GetWaveDelay())); waveIndicator.gameObject.SetActive(false); } // The number of enemies in this wave remainingEnemies = currentWave.GetNumEnemies(); // Pass the config file to the PointSpawner FindObjectOfType <PointSpawners>()?.SetWaveConfig(currentWave); // Start spawning enemies EnableSpawning(); }
private IEnumerator SpawnEnemiesInWave(WaveConfig currentWave) { for (int i = 0; i < currentWave.GetNumEnemies(); i++) { var newEnemy = Instantiate(currentWave.GetEnemyPrefab(), currentWave.GetWayPoints()[0].transform.position, Quaternion.identity); newEnemy.GetComponent <EnemyPathing>().SetWaveConfig(currentWave); yield return(new WaitForSeconds(currentWave.GetSpawnRate())); } }
private IEnumerator SpawnAllEnemiesInWave(WaveConfig waveConfig) { for (int enemyCount = 0; enemyCount < waveConfig.GetNumEnemies(); enemyCount++) { var newEnemy = Instantiate( waveConfig.GetEnemyPrefab(), waveConfig.GetWayPoints()[0].transform.position, Quaternion.identity); newEnemy.GetComponent <EnemyPathing>().SetWaveConfig(waveConfig); yield return(new WaitForSeconds(waveConfig.GetTimeBetweenSpawns())); } }