Exemple #1
0
 private IEnumerator SpawnWave(WaveConfig wave)
 {
     for (int i = 0; i < wave.GetNumOfEnemies(); i++)
     {
         var spawnPos = wave.GetWayPoints()[0].transform.position;
         SpawnSingleAlien(wave.GetEnemyPrefab(), wave);
         yield return(new WaitForSeconds(wave.GetTimeBetweenSpawns()));
     }
 }
 private IEnumerator SpawnAllEnemiesInWave(WaveConfig waveConfig)
 {
     for (int enemyCount = 0; enemyCount < waveConfig.GetNumOfEnemies(); enemyCount++)
     {
         var newEnemy = Instantiate(waveConfig.getEnemyPrefab(),
                                    waveConfig.GetWaypoints()[0].transform.position,
                                    Quaternion.identity);
         newEnemy.GetComponent <EnemyPathing>().SetWaveConfig(waveConfig);
         yield return(new WaitForSeconds(waveConfig.GetTimeBetweenSpawns()));
     }
 }
Exemple #3
0
 IEnumerator SpawnWave(WaveConfig waveConfig)
 {
     for (int i = 0; i < waveConfig.GetNumOfEnemies(); i++)
     {
         enemy = Instantiate(
             waveConfig.GetEnemyPrefab(),
             waveConfig.GetWaypoints()[0].transform.position,
             Quaternion.identity);
         enemy.GetComponent <EnemyPathing>().SetWaveConfig(waveConfig);
         yield return(StartCoroutine(Timer.Delay(waveConfig.GetSpawnInterval())));
     }
 }
 // A coroutine is a function that can suspend its execution (yield)
 // until the given YieldInstruction finishes.
 private IEnumerator SpawnEnemiesInOneWave(WaveConfig waveConfig)
 {
     for (int i = 0; i < waveConfig.GetNumOfEnemies(); i++)
     {
         var newEnemy = Instantiate(
             waveConfig.GetEnemyPrefab(),
             waveConfig.GetWavepoints()[0].position,
             Quaternion.identity
             );
         newEnemy.GetComponent <EnemyPathing>().SetWaveConfig(waveConfig);
         yield return(new WaitForSeconds(waveConfig.GetSpawnGap()));
     }
 }
Exemple #5
0
 IEnumerator SpawnEnemies()
 {
     for (int i = 0; i <= waveConfig.GetNumOfEnemies(); i++)
     {
         waypoints = waveConfig.GetWaypoints();
         Instantiate(
             waveConfig.GetEnemyPrefab(),
             waypoints[0].transform.position,
             Quaternion.identity
             );
         yield return(new WaitForSeconds(waveConfig.GetTimeBetweenSpawns()));
     }
 }
    //coroutine to spawn every enemy in a given wave
    IEnumerator SpawnAllEnemiesInWave(WaveConfig currentWave)
    {
        for (int i = 0; i < currentWave.GetNumOfEnemies(); i++)
        {
            var newEnemy = Instantiate(
                currentWave.GetEnemyPrefab(),
                currentWave.GetWaypoints()[0].transform.position,
                Quaternion.identity
                );
            newEnemy.GetComponent <EnemyPathing>().SetWaveConfig(currentWave);

            yield return(new WaitForSeconds(currentWave.GetTimeBetweenSpawns()));
        }
    }
    private IEnumerator SpawnAllEnemiesInWave(WaveConfig waveConfig)
    {
        yield return(new WaitForSeconds(waveConfig.GetTimeBeforeWave()));

        for (int i = 0; i < waveConfig.GetNumOfEnemies(); i++)
        {
            var newEnemy = Instantiate(
                waveConfig.GetEnemyPrefab(),
                waveConfig.GetPath().GetPathCurves()[0][0].position,
                Quaternion.identity);
            newEnemy.GetComponent <EnemyPathing>().SetWaveConfig(waveConfig);

            yield return(new WaitForSeconds(waveConfig.GetTimeBetweenSpawns()));
        }
    }
    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()));
        }
    }