コード例 #1
0
        private void UpdateWaves(GameTime gameTime)
        {
            // Update only if..
            // - base/medium mode - all creeps are killed
            // - hardcore mode - everytime
            var hasUnfinishedWave = false;

            if (GameDifficult != EGameDifficult.Hard)
            {
                if (Waves.Any(wave => wave.Finished == false))
                {
                    hasUnfinishedWave = true;
                }
            }

            if (hasUnfinishedWave == false)
            {
                mSpawnTimer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                if (mSpawnTimer > mSpawnInterval)
                {
                    UpgradeWaveStatsByDifficult();
                    int spawnPoint = BuildWave();

                    Status.Wave++;
                    mSpawnTimer = 0f;

                    if ((Status.Wave % mNumberOfWavesPerStage) == 0)
                    {
                        int bossCount = Math.Max((Status.Wave / 10), 1);
                        for (int i = 0; i < bossCount; i++)
                        {
                            mWaves[mWaves.Count - 1].CreateBoss(Spawns[spawnPoint], texUnit, texUnitDead);
                        }
                    }
                }
            }

            for (int i = 0; i < mWaves.Count; i++)
            {
                mWaves[i].Update(gameTime);
                if (mWaves[i].Finished)
                {
                    mWaves.RemoveAt(i);
                    i--;
                }
            }
        }
コード例 #2
0
            public override void EndOfSheetInitialize()
            {
                Waves.Sort((left, right) =>
                {
                    if (left.Number > right.Number)
                    {
                        return(1);
                    }
                    if (left.Number < right.Number)
                    {
                        return(-1);
                    }
                    return(0);
                });

                HasBoss         = Waves.Any(wave => wave.HasBoss);
                TotalMonsterIds = new List <int>();
                TotalMonsterIds.AddRange(Waves.SelectMany(wave => wave.Monsters)
                                         .Select(monster => monster.CharacterId)
                                         .Distinct());
            }