public void NewGameReset() { deathTimer = 60; gameEntities.Clear(); if (gameEntities.Contains(player)) { gameEntities.Remove(player); } player = new TheTransmission(new Vector2(300, 700), team: 1); }
protected override void Update(GameTime gameTime) { elapsedTime = gameTime.TotalGameTime; colorCounter++; if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } switch (gameState) { case GameScene.MainMenu: #region menus Controls.ModifyControlSettings(); menu.Manage(); break; #endregion case GameScene.Combat: #region combat if (Controls.JustPushedPause()) { gameState = GameScene.MainMenu; menu.LoadPause(); } if (gameEntities.Contains(player)) { player.PlayerMovement(); } if (!gameEntities.Contains(boss)) { boss = null; } if (!gameEntities.Contains(player)) { deathTimer--; if (deathTimer <= 0) { gameState = GameScene.MainMenu; menu.LoadGameOver(); } } for (int s = 0; s < BeamShips.Count; s++) { if (!gameEntities.Contains(BeamShips[s]) || BeamShips[s].team != 0) { BeamShips.RemoveAt(s); } } for (int s = 0; s < InfectedBeamShips.Count; s++) { if (!gameEntities.Contains(InfectedBeamShips[s])) { InfectedBeamShips.RemoveAt(s); } } //make enemy ships act as fleet for (int s = 0; s < enemyFleet.Count; s++) { if (!gameEntities.Contains(enemyFleet[s]) || enemyFleet[s].team != 0) { enemyFleet.RemoveAt(s); } } bool noneActing = true; foreach (Ship ship in enemyFleet) { if (ship.IsActing()) { noneActing = false; } } if (noneActing && enemyFleet.Count > 0) { actCooldown--; if (actCooldown == 0) { Ship[] makeTheseAct = enemyFleet.Draw(Math.Min(currentWaveIntensity, enemyFleet.Count)); foreach (Ship ship in makeTheseAct) { ship.Act(random.Next(60)); } } } else { actCooldown = hard ? 30 : 120; } if (enemyFleet.Count == 0 && !BossIsActive()) { betweenWaveTimer--; if (betweenWaveTimer <= 0) { betweenWaveTimer = 120; player.health = player.maxHealth; if (player.health > player.maxHealth) { player.health = player.maxHealth; } if (wave + stage * 11 > totalProgress) { totalProgress = wave + stage * 11; } Save(); if (wave >= 10) { switch (stage) { case 0: boss = new ShieldedCarrier(new Vector2(300, -100)); break; case 1: boss = new GeminiManager(new Vector2(0, 0)); break; case 2: boss = new Pulsar(new Vector2(300, -100)); break; case 3: boss = new Jupiter(new Vector2(300, 1094)); break; case 4: boss = new TheAndromeda(new Vector2(0, -300)); break; } new Message((stage == 4 ? "Final " : "") + "Boss Approaches!", new Vector2(300, 400)); } else { Fleet.gameFleets[wave, stage].LoadFleet(); Ship.trigCounter = 0; new Message("Wave " + (stage + 1) + "-" + (wave + 1), new Vector2(300, 400)); actCooldown = 180; wave++; } } } Ship.trigCounter += (float)Math.PI / 240; for (int e = 0; e < gameEntities.Count; e++) { gameEntities[e].Physics(); } for (int e = 0; e < gameEntities.Count; e++) { gameEntities[e].MainUpdate(); gameEntities[e].SpecialUpdate(); } for (int e = 0; e < gameEntities.Count; e++) { gameEntities[e].UpdateHitbox(); } if (BossIsActive() && boss is Jupiter) { ScrollCameraTo(400); } else { ScrollCameraTo(700); } break; #endregion case GameScene.Intro: #region intro if (capsule != null && gameEntities.Contains(capsule)) { capsule.rotation += (float)Math.PI / 120; if (colorCounter % 15 == 0) { new Particle(capsule.Position, Functions.PolarVector(1, capsule.rotation - (float)Math.PI / 4), random.Next(2), 60); new Particle(capsule.Position, Functions.PolarVector(1, capsule.rotation - (float)Math.PI / 4 + (float)Math.PI), random.Next(2), 60); } } if (player != null) { if (player.Position.Y > 700) { player.Position.Y -= 2; } else if (capsule != null) { gameEntities.Remove(capsule); } } if (Controls.JustPushedMenuSelect()) { if (capsule != null) { gameEntities.Remove(capsule); } gameState = GameScene.MainMenu; NewGameReset(); Sounds.PlayMusic(0); menu.LoadMainMenu(); } if (introDIalougeMessage == null || introDIalougeMessage.Complete()) { introTimer++; if (introIncrimenter >= 5) { if (introTimer > 60) { gameState = GameScene.MainMenu; menu.LoadMainMenu(); NewGameReset(); } } else if (introTimer > 60) { introTimer = 0; Vector2 msgAt = new Vector2(300, 100 + introIncrimenter * 50); switch (introIncrimenter) { case 0: introDIalougeMessage = new Message("What is that strange Object?", msgAt, -1); break; case 1: player = new TheTransmission(new Vector2(300, 820), team: 1); introDIalougeMessage = new Message("Let's investigate.", msgAt, -1); break; case 2: introDIalougeMessage = new Message("It seems to be some sort of capsule", msgAt, -1); break; case 3: introDIalougeMessage = new Message("Open it!", msgAt, -1); break; case 4: for (int i = 0; i < 80; i++) { new Particle(player.Position, Functions.PolarVector((float)random.NextDouble() * 6f, Functions.RandomRotation()), Miasma.random.Next(2), 45); } introDIalougeMessage = new Message("You dare disturb my slumber!", msgAt, -1, true); break; } introIncrimenter++; } } #endregion break; case GameScene.PickUpgrade: #region UpgradeMode upgradeSceneTimer++; if (upgradeSceneTimer > 60) { if (Controls.JustPushedRight()) { upgradeSelected++; if (upgradeSelected > 3) { upgradeSelected = 0; } } if (Controls.JustPushedLeft()) { upgradeSelected--; if (upgradeSelected < 0) { upgradeSelected = 3; } } if (Controls.JustPushedShoot() || Controls.JustPushedMenuSelect()) { player.upgrades[stage] = upgradeOptions[upgradeSelected]; RemoveUpgradeFromPool(upgradeOptions[upgradeSelected].getId()); NextStage(); } } #endregion break; case GameScene.Outro: if (Controls.JustPushedMenuSelect()) { gameState = GameScene.MainMenu; NewGameReset(); menu.LoadMainMenu(); } if (introDIalougeMessage == null || introDIalougeMessage.Complete()) { introTimer++; if (introIncrimenter >= 7) { if (introTimer > 60) { introIncrimenter = 0; if (toCredits) { gameState = GameScene.MainMenu; Sounds.PlayMusic(0); menu.LoadMainMenu(); NewGameReset(); } else { messages.Clear(); toCredits = true; } } } else if (introTimer > 60) { introTimer = 0; Vector2 msgAt = new Vector2(300, 100 + introIncrimenter * 50); if (toCredits) { switch (introIncrimenter) { case 0: introDIalougeMessage = new Message("Miasma", msgAt, -1, true); break; case 2: introDIalougeMessage = new Message("Programming and Art by", msgAt, -1); introTimer = 50; break; case 3: introDIalougeMessage = new Message("Noah Linde", msgAt, -1); break; case 4: introDIalougeMessage = new Message("Sound Design by", msgAt, -1); introTimer = 50; break; case 5: introDIalougeMessage = new Message("Michel Linde", msgAt, -1); break; case 6: introDIalougeMessage = new Message("Thank you for playing.", msgAt, -1, true); break; } } else { switch (introIncrimenter) { case 0: introDIalougeMessage = new Message("... All of our weapons are offline", msgAt, -1); playerGoHere = new Vector2(300, 700); break; case 1: introDIalougeMessage = new Message("Your ship is mine!", msgAt, -1, true); playerGoHere = new Vector2(300, -100); introTimer = -120; break; case 2: introDIalougeMessage = new Message("And so in the end", msgAt, -1); cutSceneAndromeda.flyTo = new Vector2(0, 900); introTimer = 50; break; case 3: introDIalougeMessage = new Message("the Miasma flew to the edge of space.", msgAt, -1); break; case 4: introDIalougeMessage = new Message("With the largest fuel reserve in", msgAt, -1); introTimer = 50; break; case 5: introDIalougeMessage = new Message("the galaxy and no intention on stopping.", msgAt, -1); break; case 6: introDIalougeMessage = new Message("Finally none shall disturb my slumber!", msgAt, -1, true); break; } } introIncrimenter++; } } if ((player.Position - playerGoHere).Length() < 8) { player.Position = playerGoHere; player.Velocity = Vector2.Zero; if (introIncrimenter == 2 && !toCredits) { for (int d = 0; d < 5; d++) { new Particle((leftSide + random.Next(400)) * Vector2.UnitX, Functions.PolarVector((float)random.NextDouble() * 10f, (float)Math.PI / 2 - (float)Math.PI / 8 + (float)random.NextDouble() * (float)Math.PI / 4), random.Next(2), 60); } } } else { player.Velocity = Functions.PolarVector(8, Functions.ToRotation(playerGoHere - player.Position)); } for (int e = 0; e < gameEntities.Count; e++) { gameEntities[e].Physics(); } for (int e = 0; e < gameEntities.Count; e++) { gameEntities[e].MainUpdate(); gameEntities[e].SpecialUpdate(); } for (int e = 0; e < gameEntities.Count; e++) { gameEntities[e].UpdateHitbox(); } break; } for (int p = 0; p < gameParticles.Count; p++) { gameParticles[p].ParticleUpdate(); } for (int m = 0; m < messages.Count; m++) { messages[m].UpdateMessage(); } base.Update(gameTime); }