Пример #1
0
        public static void Init(GraphicsDevice graphics)
        {
            UnlockedTowers = 0;
            rnd            = new Random();
            UiManager.UiScreens.Clear();
            UiSideScreen = new UiSideGameScreen(graphics);
            UiTopScreen  = new UiTopGameScreen(graphics);
            WaveManager.Reset();
            EnemyManager.Init();
            EnemyListener.InitiliseListener();
            TowerManager.Init();
            TowerListener.InitiliseListener();
            TroopManager.Init();
            TroopListener.InitiliseListener();
            QuestionPopUpManager.Init();

            // CHEATY TEST !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

            /*UnlockedTowers |= Unlocks.RocketTower;
             * UnlockedTowers |= Unlocks.SamTower;
             * UnlockedTowers |= Unlocks.TeslaTower;
             * UnlockedTowers |= Unlocks.Upgrade;
             * ModifyResources(100000);
             * for (int i = 0; i < 100; i++)
             *  TroopManager.SpawnTroop();*/
        }
Пример #2
0
        public static void Update(GameTime gameTime)
        {
            if (mouseSqrCoords != null)
            {
                MouseScreenPos = new Vector2(mouseSqrCoords.x * SQUARESIZE, mouseSqrCoords.y * SQUARESIZE + BORDERTOP);
            }

            m_manPower = TroopListener.TroopList.Count();

            UiSideScreen.Update();
            UiTopScreen.Update();

            QuestionPopUpManager.Update();
            WaveManager.Update(gameTime);
            TowerManager.Update();
            TroopManager.Update(gameTime);
            EffectManager.Update(gameTime);
            PopUpTextManager.Update(gameTime);
            PopUpNotificationManager.Update(gameTime);
            MessageBoxManager.Update(gameTime);

            if (BaseHealth <= 0)
            {
                if (EffectManager.EffectList.Count < 10)
                {
                    for (int i = 0; i < 1; i++)
                    {
                        EffectManager.EffectCall(EffectManager.EffectEnums.Explosion, new Vector2(ENDPOINT.x * SQUARESIZE + rnd.Next(-30, 60), ENDPOINT.y * SQUARESIZE + BORDERTOP + rnd.Next(-30, 60)), true);
                    }
                }

                GameState = GameStates.LoseScreen;
            }

            if (GameState == GameStates.LoseScreen && SaveData)
            {
                SaveData             = false;
                Scores.AllTimeKills += WaveManager.EnemiesKilled;
                if (Scores.HighestWaveKills <= WaveManager.EnemiesKilled && Scores.HighestWave <= WaveManager.WaveNumber)
                {
                    Scores.HighestWaveKills = WaveManager.EnemiesKilled;
                    Scores.HighestWave      = WaveManager.WaveNumber;
                }

                Scores.SaveData(Scores);
            }

            if (GameState == GameStates.PlayScreen && !SaveData)
            {
                SaveData = true;
            }

            if (HelpMode)
            {
                HelpDialogManager.Update();
            }
        }
Пример #3
0
        public static void Draw(SpriteBatch sb)
        {
            EffectManager.Draw(sb, 0);
            TowerManager.Draw(sb);
            EnemyManager.Draw(sb);
            TroopManager.Draw(sb);
            EffectManager.Draw(sb, 1);
            PopUpTextManager.Draw(sb);
            QuestionPopUpManager.Draw(sb);
            PopUpNotificationManager.Draw(sb);
            MessageBoxManager.Draw(sb);

            if (HelpMode)
            {
                HelpDialogManager.Draw(sb);
            }
        }
Пример #4
0
 //costs stuff
 public static void TowerWasBuilt(string TowerType)
 {
     if (TowerType == "Gun")
     {
         m_resources -= BuildManager.Resources;
         TroopManager.DestroyTroop(BuildManager.ManPower);
     }
     else if (TowerType == "Rocket")
     {
         m_resources -= BuildManager.Resources;
         TroopManager.DestroyTroop(BuildManager.ManPower);
     }
     else if (TowerType == "SAM")
     {
         m_resources -= BuildManager.Resources;
         TroopManager.DestroyTroop(BuildManager.ManPower);
     }
     else if (TowerType == "Tesla")
     {
         m_resources -= BuildManager.Resources;
         TroopManager.DestroyTroop(BuildManager.ManPower);
     }
 }
Пример #5
0
 public static void TowerWasUpgraded()
 {
     m_resources -= BuildManager.Resources;
     TroopManager.DestroyTroop(BuildManager.ManPower);
 }
Пример #6
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);
            }
        }