Exemplo n.º 1
0
    private IEnumerator SpawnEnemies(EnemyWave newWave)
    {
        currentEnemyInWaveIndex = 0;
        var spawnDelay = newWave.GetSpawnDelay();

        while (currentEnemyInWaveIndex < newWave.WaveSize)
        {
            var newEnemy = Instantiate(newWave.GetEnemyOnIndex(currentEnemyInWaveIndex++), spawnPoint.transform.position, Quaternion.Euler(new Vector3(0, spawnYRotation, 0)));
            newEnemy.transform.parent = gameObject.transform;

            yield return(new WaitForSeconds(spawnDelay));
        }

        currentWaveIndex++;

        StartCoroutine(SpawnWave());
    }