IEnumerator SpawnAllEnemiesInWave(WaveConfig currentWave)
    {
        for (var i = 0; i < currentWave.GetAllWaypoints().Count; i++)
        {
            var enemy = Instantiate(currentWave.GetEnemyPrefab(), currentWave.GetAllWaypoints()[i].transform.position, Quaternion.identity);
            enemy.AddComponent <EnemyGroupPathing>();
            enemy.GetComponent <EnemyGroupPathing>().SetSpeedOfWave(currentWave.GetMovementSpeed());
        }

        yield return(new WaitForSeconds(timeBetweenSpawns));
    }
Exemple #2
0
 // Use this for initialization
 void Start()
 {
     if (waveConfig != null)
     {
         waypoints          = waveConfig.GetAllWaypoints();
         transform.position = waypoints[waypointIndex].transform.position;
     }
 }
 IEnumerator SpawnAllEnemiesInWave(WaveConfig currentWave)
 {
     for (var enemyCount = 0; enemyCount < currentWave.GetNumberOfEnemies(); enemyCount++)
     {
         var enemy = Instantiate(currentWave.GetEnemyPrefab(), currentWave.GetAllWaypoints()[0].transform.position, Quaternion.identity);
         enemy.GetComponent <EnemyPathing>().SetWaveConfig(currentWave);
         yield return(new WaitForSeconds(currentWave.GetTimeBetweenSpawns()));
     }
 }