public override void HandleInput(GamePadState gamePadState, KeyboardState keyState, MouseState mouseState) { if (InputHandler.WasKeyPressed(keyState, KeyConfig.KeyList[0], 10)) { menu.SelectionUp(); } if (InputHandler.WasKeyPressed(keyState, KeyConfig.KeyList[1], 10)) { menu.SelectionDown(); } if (InputHandler.WasKeyPressed(keyState, KeyConfig.KeyList[4], 10)) { switch (menu.GetSelection()) { case 0: ScreenHandler.SwitchScreen(new GameScreen(graphics, content, font)); break; case 1: break; case 2: break; case 3: ScreenHandler.PushScreen(new OptionScreen(graphics, content, font)); break; case 4: break; } } if (InputHandler.WasKeyPressed(keyState, KeyConfig.KeyList[5], 10)) { ScreenHandler.SwitchScreen(new TitleScreen(graphics, content, font)); } }
/// <summary> /// Handle the inputs /// </summary> public override void HandleInput(GamePadState gamePadState, KeyboardState keyState, MouseState mouseState) { if (!player.isMoving && !lua.IsExecuting) { if (!inMenu) { //DEBUG BATTLE ENGINE TESTING if (Input.InputHandler.WasKeyPressed(keyState, Keys.B, 10)) { //testing battle engine here ///////////////////////////// startBattle(); ///////////////////////////// } //DEBUG BCUT SCENE TESTING if (Input.InputHandler.WasKeyPressed(keyState, Keys.C, 10)) { //testing cut scenes here ///////////////////////////// StartCutScene(); ///////////////////////////// } //DEBUG BCUT SCENE TESTING if (Input.InputHandler.WasKeyPressed(keyState, Keys.M, 10)) { //testing cut scenes here ///////////////////////////// StartCinematic(); ///////////////////////////// } if (keyState.IsKeyDown(KeyConfig.KeyList[2])) { player.tryToMove("Left"); } else if (keyState.IsKeyDown(KeyConfig.KeyList[3])) { player.tryToMove("Right"); } else if (keyState.IsKeyDown(KeyConfig.KeyList[0])) { player.tryToMove("Up"); } else if (keyState.IsKeyDown(KeyConfig.KeyList[1])) { player.tryToMove("Down"); } //if the action key is pressed while on the game world if (Input.InputHandler.WasKeyPressed(keyState, KeyConfig.KeyList[4], 10)) { switch (player.facing) { case PC.FacingDirection.East: interactWithTile(player.tileCoords.X + 1, player.tileCoords.Y); interectWithNPC(player.tileCoords.X + 1, player.tileCoords.Y); break; case PC.FacingDirection.West: interactWithTile(player.tileCoords.X - 1, player.tileCoords.Y); interectWithNPC(player.tileCoords.X - 1, player.tileCoords.Y); break; case PC.FacingDirection.North: interactWithTile(player.tileCoords.X, player.tileCoords.Y - 1); interectWithNPC(player.tileCoords.X, player.tileCoords.Y - 1); break; case PC.FacingDirection.South: interactWithTile(player.tileCoords.X, player.tileCoords.Y + 1); interectWithNPC(player.tileCoords.X, player.tileCoords.Y + 1); break; } } //more key handles here if (mouseState.LeftButton == ButtonState.Pressed) //zoom in { GameDraw.cameraOffset -= new Vector3(0, 0.6f, 0.3f); } if (mouseState.RightButton == ButtonState.Pressed) //zoom out { GameDraw.cameraOffset += new Vector3(0, 0.6f, 0.3f); } if (mouseState.MiddleButton == ButtonState.Pressed) //reset camera { GameDraw.cameraOffset = new Vector3(0.0f, 30.0f, 26.0f); } if (InputHandler.WasKeyPressed(keyState, KeyConfig.KeyList[6], 10)) { inMenu = true; } } else { if (InputHandler.WasKeyPressed(keyState, KeyConfig.KeyList[5], 10)) { inMenu = false; } if (InputHandler.WasKeyPressed(keyState, KeyConfig.KeyList[1], 10)) { menu.SelectionDown(); } if (InputHandler.WasKeyPressed(keyState, KeyConfig.KeyList[0], 10)) { menu.SelectionUp(); } if (InputHandler.WasKeyPressed(keyState, KeyConfig.KeyList[4], 10)) { switch (menu.GetSelection()) { // pokedex case 0: // trainer case 1: // pokemon case 2: // bag case 3: // save case 4: break; // options case 5: ScreenHandler.PushScreen(new OptionScreen(graphics, content, font)); break; } } } } }
public override void HandleInput(GamePadState gamePadState, KeyboardState keyboardState, MouseState mouseState) { if (!isSelectingKey) { if (InputHandler.WasKeyPressed(keyboardState, KeyConfig.KeyList[1], 10)) { if (!inKeyMenu) { optionsMenu.SelectionDown(); } else { if (!isSelectingKey) { keyconfigMenu.SelectionDown(); } } } if (InputHandler.WasKeyPressed(keyboardState, KeyConfig.KeyList[2], 10)) { if (!inKeyMenu) { switch (optionsMenu.GetSelection()) { case 0: ScreenHandler.GameOptions.TextSpeed = ScreenHandler.GameOptions.TextSpeed > 0 ? (byte)(ScreenHandler.GameOptions.TextSpeed - 1) : (byte)2; break; case 1: ScreenHandler.GameOptions.BattleScene = ScreenHandler.GameOptions.BattleScene ? false : true; break; case 2: ScreenHandler.GameOptions.BattleStyle = ScreenHandler.GameOptions.BattleStyle ? false : true; break; case 3: ScreenHandler.GameOptions.Sound = ScreenHandler.GameOptions.Sound ? false : true; break; } } UpdateBaseOption(optionsMenu.GetSelection()); } if (InputHandler.WasKeyPressed(keyboardState, KeyConfig.KeyList[3], 10)) { if (!inKeyMenu) { switch (optionsMenu.GetSelection()) { case 0: ScreenHandler.GameOptions.TextSpeed = ScreenHandler.GameOptions.TextSpeed < 2 ? (byte)(ScreenHandler.GameOptions.TextSpeed + 1): (byte)0; break; case 1: ScreenHandler.GameOptions.BattleScene = ScreenHandler.GameOptions.BattleScene ? false : true; break; case 2: ScreenHandler.GameOptions.BattleStyle = ScreenHandler.GameOptions.BattleStyle ? false : true; break; case 3: ScreenHandler.GameOptions.Sound = ScreenHandler.GameOptions.Sound ? false : true; break; } UpdateBaseOption(optionsMenu.GetSelection()); } } if (InputHandler.WasKeyPressed(keyboardState, KeyConfig.KeyList[0], 10)) { if (!inKeyMenu) { optionsMenu.SelectionUp(); } else { if (!isSelectingKey) { keyconfigMenu.SelectionUp(); } } } if (InputHandler.WasKeyPressed(keyboardState, KeyConfig.KeyList[5], 10)) { if (!inKeyMenu) { Close(); } else { if (!isSelectingKey) { inKeyMenu = false; } } } if (InputHandler.WasKeyPressed(keyboardState, KeyConfig.KeyList[4], 10)) { if (!inKeyMenu) { switch (optionsMenu.GetSelection()) { case 4: inKeyMenu = true; break; case 6: ScreenHandler.GameOptions.Save(); break; case 7: Close(); break; } } else { if (!isSelectingKey) { int i = keyconfigMenu.GetSelection(); if (i < keyconfigMenu.GetOptionList().Count - 3) { isSelectingKey = true; } else if (i == keyconfigMenu.GetOptionList().Count - 3) { KeyConfig.Save(); } else { inKeyMenu = false; } } } } } else { int i = keyconfigMenu.GetSelection(); Keys[] selectedKeys = InputHandler.GetSelectedKeys(keyboardState, 10); if (selectedKeys.Length > 0 && !selectedKeys[0].Equals(Keys.None) && !checkIfKeyExists(selectedKeys[0])) { KeyConfig.KeyList[i] = selectedKeys[0]; UpdateKeyOption(i); isSelectingKey = false; } } }