Beispiel #1
0
    /* Spawns a group of enemies and sets their waypoints. */
    void SpawnEnemyGroup(WavePrefabEntry wavePrefabEntry, EnemyWaveModifierType waveModifier)
    {
        foreach (EnemyGroup group in wavePrefabEntry.enemyGroups)
        {
            int groupSize = group.groupSize;

            /* Apply SWARMING wave modifier, if necessary. */
            if (waveModifier == EnemyWaveModifierType.SWARMING)
            {
                groupSize *= 2;
            }

            /* Spawn group of enemies. */
            foreach (GameObject spawner in spawners)
            {
                for (int i = 0; i < groupSize; i++)
                {
                    EnemyBaseController newEnemy        = Instantiate(group.enemyPrefab);
                    Vector3             spawnerPosition = spawner.transform.position;

                    newEnemy.ApplyWaveModifier(waveModifier);
                    newEnemy.transform.position = spawnerPosition;
                    newEnemy.transform.Translate(Vector3.back * 0.5f);
                    newEnemy.setPath(spawner.GetComponent <SpawnerTile> ().pathPoints);
                }
            }
        }
    }
Beispiel #2
0
    /* Gets the next wave. If there are preset waves left, picks the next one.
     * Otherwise, returns a random wave. */
    EnemyWave GetNextWave()
    {
        EnemyWave newWave;

        if (presetEnemyWaves.Count > 0)
        {
            newWave = presetEnemyWaves [0];
            presetEnemyWaves.RemoveAt(0);
        }
        else
        {
            /* Generate a random wave. */
            WavePrefabEntry       randomEntry  = wavePrefabEntries[Random.Range(0, wavePrefabEntries.Length)];
            int                   groupCount   = Random.Range(randomEntry.minGroupNumber, randomEntry.maxGroupNumber + 1);
            EnemyWaveModifierType modifierType = EnemyWaveModifierType.NONE;

            /* Add a modifier if the special wave countdown is up. */
            specialWaveCountdown -= 1;
            if (specialWaveCountdown <= 0)
            {
                specialWaveCountdown = Random.Range(minSpecialWaveInterval, maxSpecialWaveInterval + 1);

                int randomIndex = Random.Range(1, modifierTypes.Length);
                modifierType = modifierTypes [randomIndex];
            }

            newWave = new EnemyWave(randomEntry.waveType, groupCount, modifierType);
        }

        return(newWave);
    }