Пример #1
0
    IEnumerator SpawnWave(Wave _wave)
    {
        Debug.Log("spawning wave" + _wave.name);
        state = SpawnState.SPAWNING;

        // Store array of the wave's prefabs
        EnemyPrefabs[] enemyPrefabs = _wave.enemyPrefabs;
        // Loop through all enemies in prefabs
        for (int x = 0; x < enemyPrefabs.Length; x++)
        {
            // Store enemy's transform of current enemy
            EnemyPrefabs enemy = enemyPrefabs[x];
            // Loop through the enemy count
            for (int i = 0; i < enemy.count; i++)
            {
                // Spawn that enemy's gameobject
                SpawnEnemy(enemy.gameObject);
                yield return(new WaitForSeconds(_wave.rate)); //wait for the amount of seconds
            }
        }

        state = SpawnState.WAITING;

        yield break; //end with break
    }
Пример #2
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Пример #3
0
    IEnumerator spawnEnemies()
    {
        isSpawning = true;

        List <EnemyEnum> waveArray        = waves[GameManager.currentWave % 24].getAsList();
        int          healthMultiplier     = 2 * (GameManager.currentWave / numDistinctWaves) + 1;
        EnemyPrefabs enemyPrefabsInstance = EnemyPrefabs.instance;

        for (int i = 0; i < waveArray.Count; i++)
        {
            GameObject enemy = (GameObject)Instantiate(enemyPrefabsInstance.getEnemyPrefabFromType(waveArray[i]), spawnLocation.position, spawnLocation.rotation);

            BaseHealth healthComponent = enemy.GetComponent <BaseHealth>();
            if (healthComponent != null && healthMultiplier > 1)
            {
                healthComponent.multiplyHealth(healthMultiplier);
            }

            yield return(new WaitForSeconds(intrawaveCountdown));
        }

        isSpawning = false;
    }