public static void QuestionsCorrectCheck() { if (questionsAnsweredCorrect > 2 && !GameManager.UnlockedTowers.HasFlag(GameManager.Unlocks.RocketTower)) { GameManager.UnlockedTowers |= GameManager.Unlocks.RocketTower; MessageBoxManager.Add(new MessageBox(MessageBoxManager.RocketTowerUnlock)); } if (questionsAnsweredCorrect > 5 && !GameManager.UnlockedTowers.HasFlag(GameManager.Unlocks.SamTower)) { GameManager.UnlockedTowers |= GameManager.Unlocks.SamTower; MessageBoxManager.Add(new MessageBox(MessageBoxManager.SAMTowerUnlock)); } if (questionsAnsweredCorrect > 8 && !GameManager.UnlockedTowers.HasFlag(GameManager.Unlocks.TeslaTower)) { GameManager.UnlockedTowers |= GameManager.Unlocks.TeslaTower; MessageBoxManager.Add(new MessageBox(MessageBoxManager.TeslaTowerUnlock)); } else if (questionsAnsweredCorrect > 11 && !GameManager.UnlockedTowers.HasFlag(GameManager.Unlocks.Upgrade)) { GameManager.UnlockedTowers |= GameManager.Unlocks.Upgrade; MessageBoxManager.Add(new MessageBox(MessageBoxManager.UpgradeTowerUnlock)); } }
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); } }