public IState UpdateContent(GameTime gameTime, Camera camera, ref GameSettings gameSettings) { camera.Position = Vector2.Zero; camera.Target = Vector2.Zero; IState nextState = this; KeyboardState keyState = Keyboard.GetState(); if (keyState.IsKeyDown(Keys.Up) && PrevKeyboardState.IsKeyUp(Keys.Up)) { optionSelection -= 1; if (optionSelection < 0) { optionSelection = optionsAmount - 1; } if (optionSelection >= optionsAmount) { optionSelection = 0; } while (!menuOptions[optionSelection].Enabled) { optionSelection -= 1; } } else if (keyState.IsKeyDown(Keys.Down) && PrevKeyboardState.IsKeyUp(Keys.Down)) { optionSelection += 1; if (optionSelection < 0) { optionSelection = optionsAmount - 1; } if (optionSelection >= optionsAmount) { optionSelection = 0; } while (!menuOptions[optionSelection].Enabled) { optionSelection += 1; } } else if (keyState.IsKeyDown(Keys.Enter) && PrevKeyboardState.IsKeyUp(Keys.Enter)) { switch (optionSelection) { case (int)Options.NEW_GAME: RandomlyGeneratedStateSpace nextStateSpace = new RandomlyGeneratedStateSpace(new CaveGeneration(), 75, 125); nextState = new PlayingState(nextStateSpace, camera, Content, Graphics, this, keyboardState: keyState); break; case (int)Options.LOAD_GAME: RandomlyGeneratedStateSpace nextSpace = new RandomlyGeneratedStateSpace(DungeonInfo); nextState = new PlayingState(nextSpace, camera, Content, Graphics, saveInfo: DungeonInfo, keyboardState: keyState); break; case (int)Options.OPTIONS: GameSettingsMenuStateSpace nextMenu = new GameSettingsMenuStateSpace(ref gameSettings); nextState = new MenuState(nextMenu, camera, Content, Graphics, this, keyboardState: keyState); break; case (int)Options.QUIT_GAME: nextState = previousState; break; } } PrevKeyboardState = Keyboard.GetState(); PrevMouseState = Mouse.GetState(); PrevGamepadState = GamePad.GetState(PlayerIndex.One); return(nextState); }
public IState UpdateContent(GameTime gameTime, Camera camera, ref GameSettings gameSettings) { IState nextState = this; KeyboardState keyState = Keyboard.GetState(); if (keyState.IsKeyDown(Keys.Escape) && PrevKeyboardState.IsKeyUp(Keys.Escape)) { nextState = previousState; nextState.SetPrevInput(Keyboard.GetState(), Mouse.GetState(), GamePad.GetState(PlayerIndex.One)); } else if (keyState.IsKeyDown(Keys.Up) && PrevKeyboardState.IsKeyUp(Keys.Up)) { optionSelection -= 1; if (optionSelection < 0) { optionSelection = optionsAmount - 1; } if (optionSelection >= optionsAmount) { optionSelection = 0; } while (!menuOptions[optionSelection].Enabled) { optionSelection -= 1; } } else if (keyState.IsKeyDown(Keys.Down) && PrevKeyboardState.IsKeyUp(Keys.Down)) { optionSelection += 1; if (optionSelection < 0) { optionSelection = optionsAmount - 1; } if (optionSelection >= optionsAmount) { optionSelection = 0; } while (!menuOptions[optionSelection].Enabled) { optionSelection += 1; } } else if (keyState.IsKeyDown(Keys.Enter) && PrevKeyboardState.IsKeyUp(Keys.Enter)) { switch (optionSelection) { case (int)Options.OPTIONS: GameSettingsMenuStateSpace nextStateSpace = new GameSettingsMenuStateSpace(ref gameSettings); nextState = new MenuState(nextStateSpace, camera, Content, Graphics, this, keyboardState: Keyboard.GetState()); break; case (int)Options.SAVE_TITLE: FileIO.SaveDungeonData(((PlayingState)previousState).GetSaveData()); nextState = new TitleState(camera, Content, Graphics, Mouse.GetState(), GamePad.GetState(PlayerIndex.One), keyState); break; case (int)Options.UNPAUSE: nextState = previousState; nextState.SetPrevInput(Keyboard.GetState(), Mouse.GetState(), GamePad.GetState(PlayerIndex.One)); break; } } PrevKeyboardState = Keyboard.GetState(); PrevMouseState = Mouse.GetState(); PrevGamepadState = GamePad.GetState(PlayerIndex.One); return(nextState); }