Beispiel #1
0
    private IEnumerator SpawnAllEnemiesInWave(WaveConfig waveConfig)
    {
        int currentWaveEnemyCount = waveConfig.GetNumberOfEnemies() + enemyIncrement;

        for (int enemyCount = 0; enemyCount < currentWaveEnemyCount; enemyCount++)
        {
            var newEnemy = Instantiate(waveConfig.GetEnemyPrefab(), waveConfig.GetWaypoints()[0].transform.position, Quaternion.identity);
            newEnemy.GetComponent <EnemyPathing>().SetWaveConfig(waveConfig);

            modifiedTimeBetweenSpawns = waveConfig.GetTimeBetwenSpawns() - speedMultiplier * waveConfig.GetTimeBetwenSpawns();
            if (modifiedTimeBetweenSpawns <= 0f)
            {
                modifiedTimeBetweenSpawns = 0.1f * waveConfig.GetTimeBetwenSpawns();
            }
            yield return(new WaitForSeconds(modifiedTimeBetweenSpawns));
        }
        analyticsManager.AddWavesCompleted();
        yield return(new WaitForSeconds(1f));
    }