public override void Update(GameTime gameTime) { // check for exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { Game1.Game.Exit(); } if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Escape)) { cleanup(); returnControl("title"); return; } // mute check checkForMute(); // pause check if (Keyboard.GetState(PlayerIndex.One).IsKeyUp(Keys.P)) { allowPause = true; } if (allowPause && Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.P)) { paused ^= true; allowPause = false; if (paused) { //MediaPlayer.Pause(); MediaPlayer.Volume /= 4; foreach (PowerUp p in PowerUp.AlivePowerUps) { p.AliveTimer.Stop(); } foreach (PowerUp p in isaac.ActivePowerUps) { p.ActiveTimer.Stop(); } } else { //MediaPlayer.Resume(); MediaPlayer.Volume *= 4; foreach (PowerUp p in PowerUp.AlivePowerUps) { p.AliveTimer.Start(); } foreach (PowerUp p in isaac.ActivePowerUps) { p.ActiveTimer.Start(); } } } if (paused) { return; } //show fps every 1 second fpsElapsedTime += gameTime.ElapsedGameTime; if (fpsElapsedTime > TimeSpan.FromSeconds(1)) { Game1.Game.Window.Title = "FPS: " + frameCounter; fpsElapsedTime -= TimeSpan.FromSeconds(1); frameCounter = 0; } isaacHurtAnimation.Update(); //isaacHurtMove(gameTime); spawnPotions(gameTime); moveIsaac(gameTime); Bullet.moveBullets(gameTime); rotatePeanuts(gameTime); Fireball.moveFireballs(gameTime); rotateFireballs(gameTime); Laser2.UpdateLasers(gameTime); SeekerSnake.UpdateSeekerSnakes(gameTime); checkForPowerUpSpawnExpire(gameTime); isaac.CalculateCorners(); alex.CalculateCorners(); foreach (Laser2 laser in Laser2.Lasers) { laser.CalculateCorners(); } foreach (Bullet p in Bullet.Peanuts) { p.CalculateCorners(); } checkForPowerUpAcquisition(); acquirePotions(); isaacShoot(gameTime); checkForPeanutHits(); checkForSledgeHammerUse(gameTime); checkForSledgeHammerHits(); if (checkForIsaacHurt()) { isaacDeath(); cleanup(); returnControl("title"); return; } if (alex.HP == 0) { cleanup(); returnControl("postgame"); return; } alex.Update(gameTime, isaac); updateHearts(); shrinkPeanuts(gameTime); burnPeanuts(gameTime); moveBurningPeanuts(gameTime); updateSuperFireballLoopingSound(); }
public override void Update(GameTime gameTime) { // check for exit if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { Game1.Game.Exit(); } if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Escape)) { returnControl("title"); return; } if (checkForBillDeath()) { Stats.PeanutShots -= Bullet.Peanuts.Count; returnControl("endbattle1"); return; } // mute check checkForMute(); // pause check if (Keyboard.GetState(PlayerIndex.One).IsKeyUp(Keys.P)) { allowPause = true; } if (allowPause && Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.P)) { paused ^= true; allowPause = false; if (paused) { //MediaPlayer.Pause(); MediaPlayer.Volume /= 4; foreach (PowerUp p in PowerUp.AlivePowerUps) { p.AliveTimer.Stop(); } foreach (PowerUp p in isaac.ActivePowerUps) { p.ActiveTimer.Stop(); } } else { //MediaPlayer.Resume(); MediaPlayer.Volume *= 4; foreach (PowerUp p in PowerUp.AlivePowerUps) { p.AliveTimer.Start(); } foreach (PowerUp p in isaac.ActivePowerUps) { p.ActiveTimer.Start(); } } } if (paused) { return; } //show fps every 1 second fpsElapsedTime += gameTime.ElapsedGameTime; if (fpsElapsedTime > TimeSpan.FromSeconds(1)) { fpsElapsedTime -= TimeSpan.FromSeconds(1); Game1.Game.Window.Title = "FPS: " + frameCounter; //Game1.Game.Window.Title = "FPS: " + frameCounter + " | Projectiles: " + (Bullet.Peanuts.Count + Bullet.Cans.Count) + " | Powerups: " + PowerUp.AlivePowerUps.Count + " | Sound instances: " + SoundEffectManager.SoundEffectInstances.Count + "."; //Game1.Game.Window.Title = "Peanuts: " + Bullet.Peanuts.Length + " Cans: " + Bullet.Cans.Length + " Powerups: " + PowerUp.AlivePowerUps.Count; frameCounter = 0; } //Game1.Game.Window.Title = SoundEffectManager.soundEffectInstances.Count + " sound effect instances"; billStatus = bill.HP <= (bill.MaxHP * .5) ? (bill.HP <= (bill.MaxHP * .1) ? "PISSED" : "Upset") : "Normal"; if (billStatus == "Normal") { moveBillRandom(gameTime); } else if (billStatus == "Upset" && (int)(DateTime.Now - startTime).TotalSeconds % 8 != 7) { moveBillRandom(gameTime); } else { checkForBillSpray(gameTime); moveBillAngry(gameTime); if (!billIsAngry) { billIsAngry = true; timeBillGotAngry = DateTime.Now; if (billStatus == "PISSED") { currentBillMessage = LOWHPMESSAGE; } else { currentBillMessage = billMessages[rand.Next(billMessages.Length)]; } } } if ((DateTime.Now - timeBillGotAngry).TotalSeconds >= 1) { billIsAngry = false; } if (currentBillMessage == LOWHPMESSAGE && billStatus != "PISSED") { billIsAngry = false; } moveIsaac(gameTime); Bullet.moveBullets(gameTime); rotatePeanuts(gameTime); rotateCans(gameTime); checkForPowerUpSpawnExpire(gameTime); // calculate rotated positions of everything // sledgehammer is calculated in own method isaac.CalculateCorners(); foreach (Bullet b in Bullet.Cans) { b.CalculateCorners(); } if (GameSettings.ProjectileRotationCollision) { bill.CalculateCorners(); foreach (Bullet b in Bullet.Peanuts) { b.CalculateCorners(); } } checkForPowerUpAcquisition(); checkForIsaacDeath(); checkForBulletHits(); checkForBillShoot(gameTime); checkForIsaacShoot(gameTime); checkForSledgeHammerUse(gameTime); checkForSledgeHammerHits(); // clean up sound effect instances /*if (++cleanupCounter >= 60) * { * SoundEffectManager.Cleanup(); * cleanupCounter = 0; * }*/ //Game1.Game.Window.Title = "Bill's HP: " + bill.HP + "/" + bill.MaxHP + " Status: " + status; billHPString = "Bill's HP: " + bill.HP + "/" + bill.MaxHP; billStatusString = "Status: " + billStatus; }