Exemplo n.º 1
0
    IEnumerator SpawnWave()
    {
        for (int i = 0; i < Waves[waveIndex].sequences.Count; i++)
        {
            EnemySequence es = Waves[waveIndex].sequences[i];

            for (int k = 0; k < es.GetEnemyCount(); k++)
            {
                SpawnEnemy(es.GetEnemy());
                EnemySpawned.Raise();
                yield return(new WaitForSeconds(Waves[waveIndex].sequences[i].GetSpawnPace()));
            }
        }
        waveIndex++;
    }
Exemplo n.º 2
0
    private IEnumerator SpawnSequence(EnemySequence sequence)
    {
        numRunningSequences += 1;

        for (int i = 0; i < sequence.amountOfEnemies; i++)
        {
            var enemy = Instantiate(sequence.prefab, spawnTransform.position, spawnTransform.rotation);

            var enemyAiController = enemy.GetComponent <EnemyAIController>();
            enemyAiController.SetDestination(endTransform.position);



            yield return(new WaitForSeconds(1 / sequence.spawnRate));
        }

        numRunningSequences -= 1;
    }