Beispiel #1
0
    // Spawns a new enemy/bonus if needed.
    private void SpawnNewEnemy()
    {
        // Get the number of enemies to spawn.
        int enemies = mCurrentDifficulty.SpawnNumber();

        if (enemies > 0)
        {
            // Get the bonus type.
            int bonusType = GetSpawnBonusType();
            if (bonusType >= 0)
            {
                // If should spawn a bonus. Spawn one of the given type at a random position.
                mActiveObjects.Add(EnemyFactory.DispatchBonus(bonusType, (EnemyFactory.Column)UnityEngine.Random.Range(0, 3)));
            }
            else
            {
                // If should spawn an enemy. Spawn one at a random position.
                mActiveObjects.Add(EnemyFactory.Dispatch((EnemyFactory.Column)UnityEngine.Random.Range(0, 3)));
            }
        }
    }