예제 #1
0
        public static void Update(GameTime gameTime)
        {
            if (!WaveStarted)
            {
                WaveStartTimer -= gameTime.ElapsedGameTime;

                if (!waveCountPop)
                {
                    UiManager.UiScreens[1].StringList[3].Add(new UiTextString(Art.DebugFont, "Wave in 60 seconds", new Vector2(GameManager.ScreenSize.X / 3, GameManager.ScreenSize.Y / 2), Color.Red));
                    UiManager.UiScreens[1].StringList[3][UiManager.UiScreens[1].StringList[3].Count - 1].StringScale = 5f;

                    waveCountPop = true;
                }

                if (UiManager.UiScreens[1].StringList[3].Count != 0)
                {
                    UiManager.UiScreens[1].StringList[3][0].StringColour *= fade;
                    fade -= 0.001f;
                }

                if (fade <= 0)
                {
                    if (UiManager.UiScreens[1].StringList[3].Count != 0)
                    {
                        UiManager.UiScreens[1].StringList[3].RemoveAt(UiManager.UiScreens[1].StringList[3].Count - 1);
                    }
                }
            }


            if (WaveStartTimer <= TimeSpan.Zero || WaveStarted)
            {
                WaveStarted = true;

                if (WaveStarted)
                {
                    EnemyManager.Update(gameTime);

                    EnemySpawnTimer += gameTime.ElapsedGameTime;

                    if (EnemySpawnTimer.TotalMilliseconds >= WaveSpawnInterval)
                    {
                        if (WaveEnemiesSpawned != WaveEnemyAmount)
                        {
                            EnemyManager.SpawnEnemy(EnemyManager.TypeIDs[GameManager.rnd.Next(0, EnemyManager.TypeIDs.Count())], new Vector2(0, 0));
                            WaveEnemiesSpawned++;
                        }

                        EnemySpawnTimer = TimeSpan.Zero;
                    }

                    if (WaveEnemiesUsed >= WaveEnemyAmount)
                    {
                        WaveIncrease();
                    }
                }

                WaveStartTimer = TimeSpan.FromMinutes(1);
            }
        }
예제 #2
0
        public static void Update(GameTime gameTime)
        {
            if (WaveNumber == 1 && FirstWaveIntro)
            {
                FirstWaveIntro = false;
                if (MessageBoxManager.MessageBox.Count == 0)
                {
                    MessageBoxManager.Add(new MessageBox(MessageBoxManager.Introduction));
                }
            }


            if (!WaveStarted && !MessageBoxManager.MessageDisplayed && GameManager.GameState == GameManager.GameStates.PlayScreen)
            {
                if (!QuestionPopUpManager.QuestionUp)
                {
                    WaveStartTimer -= gameTime.ElapsedGameTime;
                }

                if (!WaveEndInit)
                {
                    WaveEndInit = true;

                    WaveCompositionCreator();

                    GameManager.ModifyResources(1000);

                    if (questionsAnsweredCorrect == QuestionPopUpManager.QuestionTotal)
                    {
                        GameManager.ModifyResources(WaveManager.WaveComposition.Count * 20);
                    }


                    if (QuestionPopUpManager.QuestionsArray.Count != 0)
                    {
                        GenerateQuestion();
                    }
                    if (GameManager.Manpower != 0 && GameManager.BaseHealth < 100)
                    {
                        float temp = 100 - GameManager.BaseHealth;
                        temp = temp * (GameManager.Manpower / 100);
                        GameManager.BaseHealth += temp * 5;

                        if (GameManager.BaseHealth > 100)
                        {
                            GameManager.BaseHealth = 100;
                        }
                    }

                    for (int i = 0; i < 4; i++)
                    {
                        TroopManager.SpawnTroop();
                    }
                }
            }

            if (WaveStartTimer <= TimeSpan.Zero || WaveStarted)
            {
                WaveStarted = true;

                if (WaveStarted)
                {
                    EnemyManager.Update(gameTime);

                    float    ttMili     = (GameManager.FPS * 1000 / GameRoot.targetTime.Milliseconds);
                    TimeSpan timeAdjust = new TimeSpan(0, 0, 0, 0, (int)ttMili / 1000);

                    EnemySpawnTimer += gameTime.ElapsedGameTime;

                    if (GameRoot.SpeedUp)
                    {
                        EnemySpawnTimer += timeAdjust;
                    }

                    if (EnemySpawnTimer.TotalMilliseconds >= WaveSpawnInterval)
                    {
                        if (WaveComposition.Count != 0)
                        {
                            EnemyManager.SpawnEnemy(WaveComposition[0], new Vector2(0, 0));
                            WaveComposition.RemoveAt(0);
                            WaveEnemiesSpawned++;
                        }

                        EnemySpawnTimer = TimeSpan.Zero;
                    }

                    if (EnemyListener.EnemyList.Count == 0 && WaveComposition.Count == 0)
                    {
                        WaveIncrease();
                    }
                }

                WaveStartTimer = TimeSpan.FromMinutes(1);
            }
        }