/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { // Allows the game to exit if (Constants.DEBUG && (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Tab))) { this.Exit(); } if (fading) //is fading at the moment { if (fade()) //if fade ends { if (fadeOut) //if fading out { if (nextScreen == myAction) { if (screen.nextZone != world.mapID) { world.warp(screen.nextZone, screen.nextTheme); world.setupSpawners(data.missions.activeMission); audio.playBackground(screen.nextTheme); } myAction.reset(); myAction.update(gameTime); camera.reset(); data.player.update(gameTime, data.npcs, data.bullets, camera, false); camera.Update(gameTime, data.player.position); } screen = nextScreen; fadeFrames = maxFadeFrames; fadeOut = false; } else //if fading in { fading = false; } } } else { int updateState = screen.update(gameTime); switch (updateState) { case Constants.CMD_EXIT: Exit(); break; case Constants.CMD_NONE: break; case Constants.CMD_NEW: { nextScreen = myAction; fading = true; fadeFrames = maxFadeFrames; fadeOut = true; //myAction.reset(); break; } case Constants.CMD_PAUSE: screen = new PauseScreen(Content, GraphicsDevice, audio, data, world, camera); break; case Constants.CMD_JOURNAL: screen = new BriefingScreen(Content, GraphicsDevice, audio, data, world, camera); break; case Constants.CMD_MOD: screen = new ModificationScreen(Content, GraphicsDevice, audio, data, world, camera); break; case Constants.CMD_MISSIONCOMPLETE: screen = new MissionCompleteScreen(Content, GraphicsDevice, audio, data, world, camera); break; case Constants.CMD_BACK: { screen = myAction; myAction.canShoot = false; break; } case Constants.CMD_MISSIONINFO: screen = new MissionInfoScreen(Content, GraphicsDevice, audio, data, world, camera); break; case Constants.CMD_INTRO: screen = new IntroductionScreen(Content, GraphicsDevice, audio, data, spriteBatch); break; case Constants.CMD_DEX: screen = new DexScreen(Content, GraphicsDevice, data, audio, world, camera); break; case Constants.CMD_CREDITS: screen = new CreditsScreen(Content, GraphicsDevice, audio, data); break; case Constants.CMD_TITLE: screen = new TitleScreen(Content, GraphicsDevice, audio, data); break; case Constants.CMD_GAMEOVER: screen = new GameOverScreen(Content, GraphicsDevice, audio, data, world, camera); break; case Constants.CMD_CHARINFO: screen = new CharScreen(Content, GraphicsDevice, audio, data, world, camera); break; case Constants.CMD_HELP: { if (screen is TitleScreen) { screen = new HelpScreen(Content, GraphicsDevice, audio, data, Constants.CMD_TITLE); } else if (screen is PauseScreen) { screen = new HelpScreen(Content, GraphicsDevice, audio, data, Constants.CMD_PAUSE); } else if (screen is DexScreen) { screen = new HelpScreen(Content, GraphicsDevice, audio, data, Constants.CMD_DEX); } else if (screen is MissionCompleteScreen) { screen = new HelpScreen(Content, GraphicsDevice, audio, data, Constants.CMD_MISSIONCOMPLETE); } else if (screen is MissionInfoScreen) { screen = new HelpScreen(Content, GraphicsDevice, audio, data, Constants.CMD_MISSIONINFO); } else if (screen is CharScreen) { screen = new HelpScreen(Content, GraphicsDevice, audio, data, Constants.CMD_CHARINFO); } else if (screen is BriefingScreen) { screen = new HelpScreen(Content, GraphicsDevice, audio, data, Constants.CMD_JOURNAL); } break; } case Constants.CMD_STORY: screen = new StoryScreen(Content, GraphicsDevice, audio, data, spriteBatch); break; default: break; } if (updateState != Constants.CMD_NONE) { Mouse.SetPosition(512, 384); } audio.update(); } base.Update(gameTime); }
public override int update(GameTime gameTime) { if (data.player.health <= 0.40f * data.player.maxHealth) { lowHP = true; } else { lowHP = false; } if (!canShoot && Mouse.GetState().LeftButton == ButtonState.Released) { canShoot = true; } if (data.player.gotHit) { blurEffect.AddBlur(); data.player.gotHit = false; } blurEffect.Update(gameTime); if (world.mapID != 0) { timeInMission += gameTime.ElapsedGameTime; } camera.Update(gameTime, data.player.Position); if (!data.player.update(gameTime, data.npcs, data.bullets, camera, canShoot)) { //TODO: DEATH SCREAM prepareWarp(0, 0); camera.reset(); data.npcs.clear(); data.bullets.clear(); return(Constants.CMD_GAMEOVER); } data.bullets.update(gameTime, camera, world, data.npcs, data.player, data.missions.activeMission); data.npcs.update(gameTime, data.bullets, camera, data.player, data.missions.activeMission); if (spawnNewEnemies) { if (data.missions.activeMission == data.missions.mainMission) { world.update(data.npcs, data.player, data.missions.activeMission, true); } else { world.update(data.npcs, data.player, data.missions.activeMission); } } if (data.missions.activeMission != null) { if (data.missions.activeMission.complete()) { if (spawnNewEnemies) { spawnNewEnemies = false; data.missions.activeMission.timeSpent = timeInMission; data.missions.activeMission.reward(data.player, data.mods); if (data.missions.activeMission.level > data.missions.nextModLevel) { data.mods.add(data.missions.nextModLevel); data.missions.nextModLevel += 4; } return(Constants.CMD_MISSIONCOMPLETE); } } else if (world.theme != 0) { spawnNewEnemies = true; } } return(updateKeyboardInput()); }