Exemple #1
0
        /// <summary>
        /// Loads the waves from a file.
        /// </summary>
        public void Initialize(ReferenceManager referenceManager)
        {
            reference = referenceManager;

            ObjectPoolManager objectPool = reference.objectPoolManager;

            IsInfinite = reference.gameSettings.selectedGameMode == GameSettings.GameMode.SoloNormal;

            EnemyIDs = new[]
            {
                (int)objectPool.GetTypeIdentifier(enemyTypeSetup.standardEnemyPrefab),
                objectPool.GetTypeIdentifier(enemyTypeSetup.buckshotEnemyPrefab),
                objectPool.GetTypeIdentifier(enemyTypeSetup.movingEnemyPrefab),
                objectPool.GetTypeIdentifier(enemyTypeSetup.splitterEnemyPrefab),
                objectPool.GetTypeIdentifier(enemyTypeSetup.kamikazeEnemyPrefab),
                objectPool.GetTypeIdentifier(enemyTypeSetup.splitterChildEnemyPrefab)
            };

            PathNames = new[]
            {
                "CenterPath",
                "LeftPath",
                "RightPath",
                "BackLeftPath",
                "BackRightPath"
            };

            //waves = waveLoader.LoadWaves();
        }
Exemple #2
0
        /// <summary>
        /// Initializes
        /// </summary>
        /// <param name="referenceManager"> The reference manager </param>
        public void Initialize(ReferenceManager referenceManager)
        {
            if (!IsInitialized)
            {
                reference = referenceManager;

                if (bossPrefab != null)
                {
                    IsInitialized = true;
                    ObjectPoolManager opm = reference.objectPoolManager;

                    bossObject = opm.Spawn(gameObject, opm.GetTypeIdentifier(bossPrefab),
                                           bossSpawn.position, bossSpawn.rotation, transform);

                    bossScript = bossObject.GetComponent <NewBoss>();
                    TransitionState(BossStates.Intro);
                }
                else
                {
                    Debug.LogError(GetType().Name + " - bossPrefab is not set.");
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Builds an array of lists of all enemies that should be spawned in each subwave.
        /// </summary>
        private void SetupSubwave()
        {
            if (setupSpawnGroups.Length > 0)
            {
                UnityEngine.Random.InitState((int)Time.time);
                enemyCapCount = enemyCap;
                spawnGroups   = new List <SpawnGroup>();

                List <EnemySpawn> enemySpawns = new List <EnemySpawn>();
                float             groupDelay  = -10.0f;
                float             spawnDelay  = -10.0f;

                List <PowerupSpawn> powerupSpawns = new List <PowerupSpawn>();

                for (int group = 0; group < setupSpawnGroups.Length; ++group)
                {
                    /**
                     * If this group doesn't spawn with the previous and it isn't the first
                     *  group, we shuffle the spawns and add a new SpawnGroup
                     *  to the list. Then, reset our intermediate variables.
                     */
                    if (!setupSpawnGroups[group].spawnWithPrevious && group > 0)
                    {
                        Shuffle(enemySpawns);
                        spawnGroups.Add(new SpawnGroup(groupDelay,
                                                       spawnDelay,
                                                       new List <EnemySpawn>(enemySpawns),
                                                       new List <PowerupSpawn>(powerupSpawns)));

                        // reset these, -10.0f just to be safe
                        enemySpawns.Clear();
                        groupDelay = -10.0f;
                        spawnDelay = -10.0f;
                        powerupSpawns.Clear();
                    }

                    // these are set to negative when they are "uninitialized"
                    // so we know when to get the current spawnGroup's values
                    if (groupDelay <= -1.0f || spawnDelay <= -1.0f)
                    {
                        groupDelay = setupSpawnGroups[group].spawnGroupDelay;
                        spawnDelay = setupSpawnGroups[group].spawnDelay;
                    }

                    for (int type = 0;
                         type < setupSpawnGroups[group].setupEnemySpawns.Length;
                         ++type)
                    {
                        for (int count = 0;
                             count < setupSpawnGroups[group].setupEnemySpawns[type].spawnCount;
                             ++count)
                        {
                            int typeIdentifier =
                                objectPoolManager.GetTypeIdentifier(
                                    setupSpawnGroups[group].setupEnemySpawns[type].enemyPrefab);

                            SpawnZone spawnZone = setupSpawnGroups[group].spawnZone;

                            AttackPattern attackPattern = setupSpawnGroups[group]
                                                          .setupEnemySpawns[type].attackPattern;

                            enemySpawns.Add(
                                new EnemySpawn(typeIdentifier, spawnZone, attackPattern));

                            ++enemiesToSpawn;
                        }
                    }

                    for (int powerup = 0;
                         powerup < setupSpawnGroups[group].setupPowerupSpawns.Length; ++powerup)
                    {
                        GameObject powerupPrefab = setupSpawnGroups[group]
                                                   .setupPowerupSpawns[powerup].powerupPrefab;
                        float spawnTimeDelayBase = setupSpawnGroups[group]
                                                   .setupPowerupSpawns[powerup].spawnTimeDelayBase;
                        float spawnTimeDelayRange = setupSpawnGroups[group]
                                                    .setupPowerupSpawns[powerup].spawnTimeDelayRange;

                        float spawnTime = spawnTimeDelayBase +
                                          UnityEngine.Random.Range(0.0f, spawnTimeDelayRange);

                        powerupSpawns.Add(new PowerupSpawn(powerupPrefab, spawnTime));
                    }
                }

                // The last group wasn't added because the for logic for
                // that is at the top of the for loop, so we add it here.
                Shuffle(enemySpawns);
                spawnGroups.Add(
                    new SpawnGroup(groupDelay, spawnDelay, new List <EnemySpawn>(enemySpawns),
                                   new List <PowerupSpawn>(powerupSpawns)));
            }
            else
            {
                Debug.LogError("Wave " + WaveNumber + " Subwave " +
                               SubwaveNumber + " does not have any spawn groups!");
            }
        }