private void checkForExitGame(KeyboardState ks) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) { mainGame.Exit(); } if (ks.IsKeyDown(Keys.Escape)) { mainGame.Exit(); } }
public void UpdatePause(GameTime gameTime) { switch (device) { #region UpdatePause Desktop case CurrentDevice.Desktop: MouseState mouse = Mouse.GetState(); game.IsMouseVisible = true; if (backToGameButton.isClicked == true) { pause = false; Game1.CurrentGameState = Game1.GameState.Playing; backToGameButton.isClicked = false; } else { backToGameButton.Update(mouse); } if (exitButton.isClicked == true) { game.Exit(); } else { exitButton.Update(mouse); } break; #endregion #region UpdatePause Phone case CurrentDevice.Phone: if (Keyboard.GetState().IsKeyDown(Keys.Escape)) { pause = false; Game1.CurrentGameState = Game1.GameState.Playing; } else { changeTransparency(gameTime); } if (Keyboard.GetState().IsKeyDown(Keys.Q)) { game.Exit(); } break; #endregion } }
override public void Update(Game1 game, GameTime gameTime, MouseState mouse, GamePadState gamepad, KeyboardState kb) { if (kb.IsKeyDown(Keys.Enter) || mouse.LeftButton == ButtonState.Pressed) { Game.Exit(); } }
public override void Update(GameTime gameTime) { exitButton.Update(gameTime); playButton.Update(gameTime); optionsButton.Update(gameTime); if (!title && myGame.currentGameLevel == Game1.GameLevels.MENU) { MediaPlayer.Stop(); MediaPlayer.Play(titleSong); title = true; } if (exitButton.Clicked()) { MediaPlayer.Stop(); myGame.Exit(); } if (playButton.Clicked()) { myGame.SetCurrentLevel(Game1.GameLevels.GAME); } if (optionsButton.Clicked()) { myGame.SetCurrentLevel(Game1.GameLevels.OPTIONS); } base.Update(gameTime); }
// METHODS // UPDATE and DRAW public override void Update(GameTime gameTime, Input input, Game1 game) { this.startButton.Update(gameTime, input); this.scoreButton.Update(gameTime, input); this.settingsButton.Update(gameTime, input); this.quitButton.Update(gameTime, input); if (this.startButton.IsPressed()) { game.ChangeMenu(MenuState.GAME); } if (this.settingsButton.IsPressed()) { game.ChangeMenu(MenuState.SETTINGS); } if (this.scoreButton.IsPressed()) { game.ChangeMenu(MenuState.SCORE); } if (this.quitButton.IsPressed()) { game.Exit(); } base.Update(gameTime, input, game); }
public void Execute() { int ufoPos = myGame.level.scoreSystem.menu.ufoPos; switch (ufoPos) { case 1: myGame.level.Load(GameConstants.Level1, new Vector2(GameConstants.MainCharStartingX, GameConstants.MainCharStartingY)); break; case 2: myGame.level.Load(GameConstants.Level2, new Vector2(GameConstants.MainCharStartingX, GameConstants.MainCharStartingY)); break; case 3: myGame.level.Load(GameConstants.Level3, new Vector2(GameConstants.MainCharStartingX, GameConstants.MainCharStartingY)); break; case 4: myGame.level.Load(GameConstants.Collectibles, new Vector2(GameConstants.MainCharStartingX, GameConstants.MainCharStartingY)); break; case 5: myGame.level.Load(GameConstants.Credits, new Vector2(GameConstants.MainCharStartingX, GameConstants.MainCharStartingY)); break; case 6: myGame.Exit(); break; } }
public void update(GameTime gameTime, Game1 game) { if (Input.IsPressed(Keys.Down)) { selectedOption++; if (selectedOption >= Options.Count) { selectedOption = 0; } } if (Input.IsPressed(Keys.Up)) { selectedOption--; if (selectedOption < 0) { selectedOption = Options.Count - 1; } } if (Input.IsDown(Keys.Enter)) { switch (selectedOption) { case 0: game.gameState = Game1.GameState.running; break; case 1: game.Exit(); break; } } }
public void StopGame() { if (_activeScene != null) { _activeScene.Shutdown(); } _game.Exit(); }
public override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { game.Exit(); } base.Update(gameTime); }
public void CheckKeyboard(Game1 game, float delta) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { game.Exit(); } inputManager.Update(Keyboard.GetState()); }
/// <summary> /// Den här metoden uppdaterar vad som händer när man trycker på en knapp i main manu. /// </summary> public void ButtonClickMainMenu() { if (mainMenuButtonList[0].activeButton) { GameManager.currentState = GameState.PlayerSelect; } else if (mainMenuButtonList[1].activeButton) { GameManager.currentState = GameState.Controls; } else if (mainMenuButtonList[2].activeButton) { GameManager.currentState = GameState.CharacterInfo; } else if (mainMenuButtonList[3].activeButton) { game.Exit(); } }
static void Main(string[] args) { Form1 form = new Form1(); form.Show(); game = new Game1(form.getDrawSurface(), form.getScoreLabel()); game.Run(); form.Close(); game.Exit(); }
public void Update(Game1 Game) { switch (currentState) { case Enums.MainMenuStates.MAIN: if ((Keyboard.GetState().IsKeyDown(Keys.W) || Keyboard.GetState().IsKeyDown(Keys.Up) || GamePad.GetState(0).IsButtonDown(Buttons.DPadUp) || GamePad.GetState(0).ThumbSticks.Left.Y > 0.5f) && !buttonPressed && !controlWindowOpen) { currentButton--; if (currentButton < 0) currentButton = Enums.MainMenuButtons.EXIT; buttonPressed = true; } if ((Keyboard.GetState().IsKeyDown(Keys.S) || Keyboard.GetState().IsKeyDown(Keys.Down) || GamePad.GetState(0).IsButtonDown(Buttons.DPadDown) || GamePad.GetState(0).ThumbSticks.Left.Y < -0.5f) && !buttonPressed && !controlWindowOpen) { currentButton++; if (currentButton > Enums.MainMenuButtons.EXIT) currentButton = Enums.MainMenuButtons.START; buttonPressed = true; } if ((Keyboard.GetState().IsKeyDown(Keys.Enter) || GamePad.GetState(0).IsButtonDown(Buttons.A)) && !buttonPressed) { buttonPressed = true; switch (currentButton) { case Enums.MainMenuButtons.START: controlWindowOpen = true; break; case Enums.MainMenuButtons.RESUME: Game1.currentGameState = Game1.GameState.GAMELOOP; break; case Enums.MainMenuButtons.OPTIONS: currentState = Enums.MainMenuStates.OPTION; break; case Enums.MainMenuButtons.CREDITS: Game1.currentGameState = Game1.GameState.CREDITS; break; case Enums.MainMenuButtons.EXIT: Game.Exit(); break; } } if (Keyboard.GetState().GetPressedKeys().Count() == 0 && GamePad.GetState(0).IsButtonUp(Buttons.DPadUp) && GamePad.GetState(0).IsButtonUp(Buttons.A) && GamePad.GetState(0).IsButtonUp(Buttons.DPadDown) && GamePad.GetState(0).ThumbSticks.Left.Y < 0.5f && GamePad.GetState(0).ThumbSticks.Left.Y > -0.5f) { buttonPressed = false; } break; case Enums.MainMenuStates.OPTION: options.Update(this); break; } }
public override void Selection(Game1 game) { if (selection == 1) { game.Exit(); } else if (selection == 2) { Stage.FullReset(); } }
public void Update(GameTime gametime) { KeyboardState kbState = Keyboard.GetState(); if (kbState.IsKeyDown(Keys.Space)) { currentState = new Menu(); } if (kbState.IsKeyDown(Keys.Escape)) { exit.Exit(); // ---- this object does not exist } }
public override void Update() { if (active) { if (firstOpen) { //Create widgets and such CreateWidgets(); firstOpen = false; } if (Game1.priorityGui == this) { GuiWidgetButtonString widgetButtonString = null; for (int i = widgets.Count - 1; i >= 0; i--) { if (widgets[i].id.Item1 == WidgetType.ButtonString) { widgetButtonString = (GuiWidgetButtonString)widgets[i]; widgetButtonString.Update(); if (widgets[i].id.Item2 == 0) { if (widgets[i].currentState == GuiWidget.State.Done) { Close(); } } if (widgets[i].id.Item2 == 1) { if (widgets[i].currentState == GuiWidget.State.Done) { reallyExit.Open(); } } } if (!widgets[i].active) { widgets.RemoveAt(i--); } } } reallyExit.Update(); if (reallyExit.clicked[0]) { game.Exit(); } } }
public void Update() { KeyboardState keyboardState = Keyboard.GetState(); if (keyboardState.IsKeyDown(Keys.Enter) && lastState.IsKeyUp(Keys.Enter)) { game.StartGame(); } else if (keyboardState.IsKeyDown(Keys.Escape) && lastState.IsKeyUp(Keys.Escape)) { game.Exit(); } lastState = keyboardState; }
public override void Selection(Game1 game) { if (selection == 1) { Leave(new Playing(Context)); } else if (selection == 2) { game.Exit(); } else { Stage.Reset(); } }
public void Update(GameTime gt, Game1 game) { mouseRect = new Rectangle((int)Mouse.GetState().Position.X, (int)Mouse.GetState().Position.Y, 1, 1); if (mouseRect.Intersects(playRect) && Mouse.GetState().LeftButton.Equals(ButtonState.Pressed)) { Game1.currentState = Game1.GameStates.INGAME; } if (mouseRect.Intersects(exitRect) && Mouse.GetState().LeftButton.Equals(ButtonState.Pressed)) { game.Exit(); } }
public bool Update(Game1 game, Input input) { battle.battleText = "Battle ended!"; elapsedTime += (int)Game1.time.ElapsedGameTime.TotalMilliseconds; if (elapsedTime >= eventTime) { // if there are no more alive players if (battle.aliveActors.Count == 0) { // TODO: go to a game-over event, which on its turn can go to a load-save event or a quit event game.Exit(); } else { // TODO: go to a loot event, or a level event or something like that if (battle.aliveActors.TrueForAll(x => x.isPlayer)) { game.actors = battle.actors.FindAll(x => x.isPlayer); game.nextEvent = new EventDeterminerEvent(game); } // TODO: go to a game-over event, which on its turn can go to a load-save event or a quit event if (battle.aliveActors.TrueForAll(x => !x.isPlayer)) { game.Exit(); } } return(true); } else { return(false); } }
public void update(GameTime gametime, Game1 game, ContentManager content) { if (Input.IsPressed(Keys.Up)) { SoundManager.playSound("menuswitch"); escolha--; if (escolha < 0) { escolha = options.Count - 1; } } if (Input.IsPressed(Keys.Down)) { SoundManager.playSound("menuswitch"); escolha++; if (escolha >= options.Count) { escolha = 0; } } if (Input.IsPressed(Keys.Enter)) { SoundManager.playSound("enterselect"); switch (escolha) { case 0: game.gameState = Game1.GameState.running; break; case 1: { game.gameState = Game1.GameState.Menu; CharactersHandler.Players.Clear(); MenuCharacterChoose.resetArrays(content); Collisions.reset(); Game1.firstEntry = false; } break; case 2: game.Exit(); break; } } }
public void ClickCheck(int sv, Point mousePosition, Game1 game) { if (Load.ButtonClick(mousePosition)) { game.Load(sv); } if (Quit.ButtonClick(mousePosition)) { game.Exit(); } if (BackMainMenu.ButtonClick(mousePosition)) { disableButtons(); game.BackMainMenu(); } }
public override void Update(Game1 game, GameTime gameTime) { presentMouse = Mouse.GetState(); foreach (Control control in Controls) { control.Update(presentMouse); } if (btnPLay.IsLeftClicked) { this.IsActive = false; game.LevelScreen2.IsActive = true; } if (btnQuit.IsLeftClicked) { this.IsActive = false; game.Exit(); } }
private void doEventsTitleScreen(Game1 Game) { if (btnJoin.Clicked) { _state = MenuState.Join; setJoinScreen(); m_sleepCounter = m_delay; } if (btnHost.Clicked) { _state = MenuState.Host; setHostScreen(); m_sleepCounter = m_delay; } if (btnExit.Clicked) { Game.Exit(); } }
public MainMenu(Game1 game) : base(game) { var navigation = new VerticalNavigationMenu(game.inputManager, new List <IButton>() { new TextButton(inputManager, font, "PLAY") { OnClick = (o, e) => game.ChangeState(new FirstLevel(game)) }, new TextButton(inputManager, font, "HOW TO PLAY") { OnClick = (o, e) => game.ChangeState(new HowToPlay(game)) }, new TextButton(inputManager, font, "EXIT") { OnClick = (o, e) => game.Exit() } }); navigation.Position = new Vector2(game.LogicalSize.X / 2 - navigation.Size.X / 2, game.LogicalSize.Y / 2 - navigation.Size.Y / 2); AddUiComponent(navigation); }
public void Execute() { int ufoPos = myGame.level.scoreSystem.collectibles.ufoPos; switch (ufoPos) { case 1: BackgroundMusic.instanse.playSound(BackgroundMusic.MainMenu); break; case 2: BackgroundMusic.instanse.playSound(BackgroundMusic.LevelOne); break; case 3: BackgroundMusic.instanse.playSound(BackgroundMusic.LevelTwo); break; case 4: BackgroundMusic.instanse.playSound(BackgroundMusic.LevelThree); break; case 5: BackgroundMusic.instanse.playSound(BackgroundMusic.BGM1); break; case 6: BackgroundMusic.instanse.playSound(BackgroundMusic.BGM2); break; case 7: myGame.Exit(); break; } }
public void Update() { //The following Sprint0 codes kept for test if (Keyboard.GetState().IsKeyDown(Keys.D0)) { myGame.Exit(); } if (Keyboard.GetState().IsKeyDown(Keys.D1)) { myGame.sprite = new fixedStaticSprite(myGame.luigi, 6, 14); } if (Keyboard.GetState().IsKeyDown(Keys.D2)) { myGame.sprite = new fixedAnimatedSprite(myGame.luigi, 6, 14); } if (Keyboard.GetState().IsKeyDown(Keys.D3)) { myGame.sprite = new movingStaticSprite(myGame.luigi, 6, 14); } if (Keyboard.GetState().IsKeyDown(Keys.D4)) { myGame.sprite = new movingAnimatedSprite(myGame.luigi, 6, 14); } // currentCommand = new NullCommand(); //GamePadState gamepadState = GamePad.GetState(PlayerIndex.One); Kstate = Keyboard.GetState(); foreach (Keys key in Kstate.GetPressedKeys()) { if (commandLibrary.ContainsKey(key)) { currentCommand = commandLibrary[key]; currentCommand.Execute(); } } //mario.Idle(); }
/// <summary> /// Allows the game component to update itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public override void Update(GameTime gameTime) { retry.Update(gameTime); mainMenu.Update(gameTime); exit.Update(gameTime); if (exit.Clicked()) { MediaPlayer.Stop(); myGame.Exit(); } if (mainMenu.Clicked()) { myGame.SetCurrentLevel(Game1.GameLevels.MENU); myGame.gameManager.camera.Position = new Vector2(myGame.gameManager.player.Position.X, myGame.gameManager.player.Position.Y); myGame.gameManager.player.Lives = 3; myGame.gameManager.level = 2; myGame.gameManager.levelLoaded = false; myGame.menuManager.title = false; } if (retry.Clicked()) { myGame.SetCurrentLevel(Game1.GameLevels.GAME); myGame.gameManager.camera.Position = new Vector2(myGame.gameManager.player.Position.X, myGame.gameManager.player.Position.Y); myGame.gameManager.player.Lives = 3; myGame.gameManager.levelLoaded = false; myGame.gameManager.player._Mana.mana = myGame.gameManager.player._Mana.maxMana; myGame.gameManager.player._Mana.manaRechargeTime = 5000; myGame.gameManager.player.CanShootProjectile = true; myGame.gameManager.player.HasShotProjectile = false; } // TODO: Add your update code here base.Update(gameTime); }
public void Update() { if (Mouse.GetState().RightButton == ButtonState.Pressed) { myGame.Exit(); } if (Mouse.GetState().LeftButton == ButtonState.Pressed && Mouse.GetState().X <= 400 && Mouse.GetState().Y <= 240) { myGame.sprite = new fixedStaticSprite(myGame.luigi, 6, 14); } if (Mouse.GetState().LeftButton == ButtonState.Pressed && Mouse.GetState().X > 400 && Mouse.GetState().Y <= 240) { myGame.sprite = new fixedAnimatedSprite(myGame.luigi, 6, 14); } if (Mouse.GetState().LeftButton == ButtonState.Pressed && Mouse.GetState().X <= 400 && Mouse.GetState().Y > 240) { myGame.sprite = new movingStaticSprite(myGame.luigi, 6, 14); } if (Mouse.GetState().LeftButton == ButtonState.Pressed && Mouse.GetState().X > 400 && Mouse.GetState().Y > 240) { myGame.sprite = new movingAnimatedSprite(myGame.luigi, 6, 14); } }
public void checkMouseActions(ref GameState gameState, Game1 game) { var mouseState = Mouse.GetState(); var mousePosition = new Point(mouseState.X, mouseState.Y); foreach (Menu menu in menuCollection) { if (menu.GetRect().Contains(mousePosition)) { // Hover menu.sprite.texture = menu.hoverTexture; Console.WriteLine("Hovering"); // Left click if (mouseState.LeftButton == ButtonState.Pressed) { if (menu.type == MenuType.StartMenu) { Console.WriteLine("Left Button Pressed"); gameState = GameState.Gameplay; } else if (menu.type == MenuType.CreditsMenu) { gameState = GameState.Credits; } else if (menu.type == MenuType.ExitMenu) { game.Exit(); } } } else { menu.sprite.texture = menu.defaultTexture; } } }
// Clicked event protected void WireUpEvents(Game1 game) { // if this button is for change menu state if (change != null) { Clicked += delegate(object sender, EventArgs e) { ((Button)sender).state = ButtonStatus.Up; game.Menu.ChangeState(change.Value, ((Button)sender).Text); }; } else { Clicked += delegate(object sender, EventArgs e) { ((Button)sender).state = ButtonStatus.Up; if (Text.Contains("Exit")) { game.Exit(); } if (Text.Contains("Resume")) { game.State = GameState.InGame; } }; } }
//method for mouse on main menu public Rectangle MouseClicked(int x, int y, Game1 game, ref int currentLevel, ref List<Enemy> enemies, ref List<PickUpItem> Items, ref List<Projectile> projectiles, ref int timer, ContentManager Content, ref Character player, ref string wepUnl, ref bool songPlaying, ref SoundEffectInstance song) { Rectangle mouseClickRect = new Rectangle(x, y, 1, 1); Rectangle startbuttonRect = new Rectangle((int)startButtonPosition.X, (int)startButtonPosition.Y, 300, 108); Rectangle exitbuttonRect = new Rectangle((int)exitButtonPosition.X, (int)exitButtonPosition.Y, 600, 192); if (gameState == "StartMenu") { //player clicks start if (mouseClickRect.Intersects(startbuttonRect)) { try { gameState = "Case"; CheckGameState(); } catch (GameStateNotFoundException) { gameState = "Case"; } } //player exits game else if (mouseClickRect.Intersects(exitbuttonRect)) { game.Exit(); } // player clicked on options else if (mouseClickRect.Intersects(optionsButtonPosition)) { try { gameState = "OptionsMenu"; lastState = "StartMenu"; CheckGameState(); } catch (GameStateNotFoundException e) { Console.WriteLine(e.ToString()); gameState = ""; } } else if (mouseClickRect.Intersects(levelSelectButtonPosition)) { try { gameState = "LevelSelect"; lastState = "StartMenu"; CheckGameState(); } catch (GameStateNotFoundException e) { Console.WriteLine(e.ToString()); gameState = ""; } } } //level select menu else if (gameState == "LevelSelect") { // back button clicked if (mouseClickRect.Intersects(backButtonPosition)) { try { gameState = lastState; CheckGameState(); } catch (GameStateNotFoundException e) { Console.WriteLine(e.ToString()); gameState = ""; lastState = ""; } } else if (mouseClickRect.Intersects(levelRect[0]) || mouseClickRect.Intersects(levelRect[1]) || mouseClickRect.Intersects(levelRect[2]) || mouseClickRect.Intersects(levelRect[3]) || mouseClickRect.Intersects(levelRect[4]) || mouseClickRect.Intersects(levelRect[5]) || mouseClickRect.Intersects(levelRect[6]) || mouseClickRect.Intersects(levelRect[7])) { Shooting.CreateWeapons(Content); if (mouseClickRect.Intersects(levelRect[0]) && levelClears[0] != 0) { currentLevel = 1; SkillSystem.CreateSkills(Content, player); player.Health = player.MaxHealth; player.Stamina = 100; wepUnl = ""; player.Weapon = Shooting.weapons[1]; player.FrameLevel = 1; enemies.Clear(); Items.Clear(); projectiles.Clear(); timer = 0; gameState = "LevelSwitch"; CheckGameState(); } else if (mouseClickRect.Intersects(levelRect[1]) && levelClears[1] != 0) { currentLevel = 2; Shooting.weapons[2].IsAcquired = true; SkillSystem.CreateSkills(Content, player); player.Health = player.MaxHealth; player.Stamina = 100; wepUnl = ""; player.Weapon = Shooting.weapons[1]; player.FrameLevel = 1; enemies.Clear(); Items.Clear(); projectiles.Clear(); timer = 0; gameState = "LevelSwitch"; CheckGameState(); } else if (mouseClickRect.Intersects(levelRect[2]) && levelClears[2] != 0) { currentLevel = 3; Shooting.weapons[2].IsAcquired = true; SkillSystem.CreateSkills(Content, player); player.Health = player.MaxHealth; player.Stamina = 100; wepUnl = ""; player.Weapon = Shooting.weapons[1]; player.FrameLevel = 1; enemies.Clear(); Items.Clear(); projectiles.Clear(); timer = 0; gameState = "LevelSwitch"; CheckGameState(); } else if (mouseClickRect.Intersects(levelRect[3]) && levelClears[3] != 0) { currentLevel = 4; Shooting.weapons[2].IsAcquired = true; Shooting.weapons[3].IsAcquired = true; SkillSystem.CreateSkills(Content, player); player.Health = player.MaxHealth; player.Stamina = 100; wepUnl = ""; player.Weapon = Shooting.weapons[1]; player.FrameLevel = 1; enemies.Clear(); Items.Clear(); projectiles.Clear(); timer = 0; gameState = "LevelSwitch"; CheckGameState(); } else if (mouseClickRect.Intersects(levelRect[4]) && levelClears[4] != 0) { currentLevel = 5; Shooting.weapons[2].IsAcquired = true; Shooting.weapons[3].IsAcquired = true; SkillSystem.CreateSkills(Content, player); player.Health = player.MaxHealth; player.Stamina = 100; wepUnl = ""; player.Weapon = Shooting.weapons[1]; player.FrameLevel = 1; enemies.Clear(); Items.Clear(); projectiles.Clear(); timer = 0; gameState = "LevelSwitch"; CheckGameState(); } else if (mouseClickRect.Intersects(levelRect[5]) && levelClears[5] != 0) { currentLevel = 6; Shooting.weapons[2].IsAcquired = true; Shooting.weapons[3].IsAcquired = true; Shooting.weapons[4].IsAcquired = true; SkillSystem.CreateSkills(Content, player); player.Health = player.MaxHealth; player.Stamina = 100; wepUnl = ""; player.Weapon = Shooting.weapons[1]; player.FrameLevel = 1; enemies.Clear(); Items.Clear(); projectiles.Clear(); timer = 0; gameState = "LevelSwitch"; CheckGameState(); } else if (mouseClickRect.Intersects(levelRect[6]) && levelClears[6] != 0) { currentLevel = 7; Shooting.weapons[2].IsAcquired = true; Shooting.weapons[3].IsAcquired = true; Shooting.weapons[4].IsAcquired = true; SkillSystem.CreateSkills(Content, player); player.Health = player.MaxHealth; player.Stamina = 100; wepUnl = ""; player.Weapon = Shooting.weapons[1]; player.FrameLevel = 1; enemies.Clear(); Items.Clear(); projectiles.Clear(); timer = 0; gameState = "LevelSwitch"; CheckGameState(); } else if (mouseClickRect.Intersects(levelRect[7]) && levelClears[7] != 0) { currentLevel = 8; Shooting.weapons[2].IsAcquired = true; Shooting.weapons[3].IsAcquired = true; Shooting.weapons[4].IsAcquired = true; SkillSystem.CreateSkills(Content, player); player.Health = player.MaxHealth; player.Stamina = 100; wepUnl = ""; player.Weapon = Shooting.weapons[1]; player.FrameLevel = 1; enemies.Clear(); Items.Clear(); projectiles.Clear(); timer = 0; gameState = "LevelSwitch"; CheckGameState(); } } } //Death screen else if (gameState == "Death") { if (mouseClickRect.Intersects(exitbuttonRect)) { gameState = "StartMenu"; CheckGameState(); } }//Victory state for beating the game else if (gameState == "Victory") { if (mouseClickRect.Intersects(rightStartButton)) { gameState = "StartMenu"; CheckGameState(); } }//Page for the Case story else if (gameState == "Case") { if (mouseClickRect.Intersects(rightStartButton)) { SkillSystem.CreateSkills(Content, player); Shooting.CreateWeapons(Content); player.Health = player.MaxHealth; player.Stamina = 100; wepUnl = ""; player.Weapon = Shooting.weapons[1]; player.FrameLevel = 1; currentLevel = 1; enemies.Clear(); Items.Clear(); projectiles.Clear(); timer = 0; gameState = "LevelSwitch"; CheckGameState(); } } //puased screen else if (gameState == "Paused") { if (mouseClickRect.Intersects(exitbuttonRect)) { saveLevelClears(); song.Stop(); songPlaying = false; gameState = "StartMenu"; CheckGameState(); } else if (mouseClickRect.Intersects(optionsButtonPosition)) { try { gameState = "OptionsMenu"; lastState = "Paused"; CheckGameState(); } catch (GameStateNotFoundException e) { Console.WriteLine(e.ToString()); gameState = ""; } } else if (mouseClickRect.Intersects(resumeButtonPosition)) { try { song.Resume(); gameState = "Playing"; CheckGameState(); } catch (GameStateNotFoundException e) { Console.WriteLine(e.ToString()); gameState = ""; } } } //options screen method else if (gameState == "OptionsMenu") { // back button clicked if (mouseClickRect.Intersects(backButtonPosition)) { try { gameState = lastState; CheckGameState(); } catch (GameStateNotFoundException e) { Console.WriteLine(e.ToString()); gameState = ""; lastState = ""; } } // sounds button clicked else if (mouseClickRect.Intersects(soundsButtonPosition)) { try { gameState = "SoundsMenu"; } catch (GameStateNotFoundException e) { Console.WriteLine(e.ToString()); gameState = ""; } } // graphics button clicked else if (mouseClickRect.Intersects(graphicsButtonPosition)) { try { gameState = "GraphicsMenu"; } catch (GameStateNotFoundException e) { Console.WriteLine(e.ToString()); gameState = ""; } } // controls button clicked else if (mouseClickRect.Intersects(controlButtonPosition)) { try { gameState = "Controls"; } catch (GameStateNotFoundException e) { Console.WriteLine(e.ToString()); gameState = ""; } } } // Sounds menu else if (gameState == "SoundsMenu") { if (mouseClickRect.Intersects(backButtonPosition)) { try { gameState = "OptionsMenu"; } catch (GameStateNotFoundException e) { Console.WriteLine(e.ToString()); gameState = ""; } } } // Controls menu else if (gameState == "Controls") { if (mouseClickRect.Intersects(controlBackButtonPosition)) { try { gameState = "OptionsMenu"; } catch (GameStateNotFoundException e) { Console.WriteLine(e.ToString()); gameState = ""; } } } // graphics menu else if (gameState == "GraphicsMenu") { if (mouseClickRect.Intersects(backButtonPosition)) { try { gameState = "OptionsMenu"; } catch (GameStateNotFoundException e) { Console.WriteLine(e.ToString()); gameState = ""; } } } return mouseClickRect; }
public void Update(Game1 game) { if (game.keyState.IsKeyDown(Keys.Up) && game.oldState.IsKeyUp(Keys.Up)) { if (!exitSelected && !resumeSelected) { resumeSelected = true; exitSelected = false; } else if (resumeSelected) { exitSelected = true; resumeSelected = false; } else if (exitSelected) { resumeSelected = true; exitSelected = false; } } if (game.keyState.IsKeyDown(Keys.Down) && game.oldState.IsKeyUp(Keys.Down)) { if (!exitSelected && !resumeSelected) { exitSelected = true; resumeSelected = false; } else if (resumeSelected) { exitSelected = true; resumeSelected = false; } else if (exitSelected) { resumeSelected = true; exitSelected = false; } } if (exitSelected) { exit = game.Content.Load<Texture2D>(@"Game\Menu\exitSelected"); resume = game.Content.Load<Texture2D>(@"Game\Menu\resume"); } if (resumeSelected) { exit = game.Content.Load<Texture2D>(@"Game\Menu\exit"); resume = game.Content.Load<Texture2D>(@"Game\Menu\resumeSelected"); } if (game.keyState.IsKeyDown(Keys.Enter)) { if (exitSelected) { game.Exit(); } if (resumeSelected) { Game1.currentGameState = Game1.GameState.PLAY; paused = false; } } }
public void Update(Game1 game) { oldState = currentState; currentState = Keyboard.GetState(); if ((currentState.IsKeyDown(Keys.Up) && oldState.IsKeyUp(Keys.Up)) || (currentState.IsKeyDown(Keys.Down) && oldState.IsKeyUp(Keys.Down))) { play = !play; } if (currentState.IsKeyDown(Keys.Enter)) { if (play) { game.transition = true; } else { game.Exit(); } } }