/// <summary> /// Lets the game respond to player input. Unlike the Update method, /// this will only be called when the gameplay screen is active. /// </summary> /// <param name="elapsed">Time since last update in seconds</param> public override void HandleInput(InputState input, int elapsed) { List<DialogData> dialogText; string npcName; string sampleDialogText; if (input == null) throw new ArgumentNullException("input"); // Pass the input to the engine for debugging controls MapEngine.processInput(input, elapsed / (float)1000); if (input.PauseKey) { // TODO: If they pressed pause key, display the world menu and player stats //ScreenManager.AddScreen(new PauseMenuScreen()); } else if (input.IsNewKeyPress(Keys.F)) // DEBUG testing controls { sampleDialogText = "This is a test and only a test. Hopefully, the splitter works correctly" + " and performs or exceeds my expectations. Go go parser! Work! And more text " + "is being added to help add fluff and maybe break the code so I can fix it."; List<string> testList = DialogParser.ParseString(sampleDialogText, Fonts.GeneralFont, 150, 4); ScreenManager.AddScreen(new DialogBoxScreen("Tester", testList, DialogBoxScreen.DialogSpeed.Fast, 1000)); } else if (input.IsNewKeyPress(Keys.G)) // DEBUG testing controls { List<string> testMessage = new List<string>(); testMessage.Add("This is the first part\nof this message."); testMessage.Add("This is another part\nof this message."); testMessage.Add("Last part of this cool\nmessage!!"); ScreenManager.AddScreen(new DialogBoxScreen("Tester", testMessage, DialogBoxScreen.DialogSpeed.Medium, new Vector2(100,100), new Vector2(500, 400))); } else if (input.IsNewKeyPress(Keys.H)) // DEBUG testing controls { MapEngine.FollowParty = !MapEngine.FollowParty; MapEngine.AddDebugMsg("[H] Toggling follow party"); } // Movement commands if (input.PressedDownKey) { if (!director.PartyMoving) { MapEngine.MovePlayer(MapDirection.Down); } } if (input.PressedUpKey) { if (!director.PartyMoving) { MapEngine.MovePlayer(MapDirection.Up); } } if (input.PressedLeftKey) { if (!director.PartyMoving) { MapEngine.MovePlayer(MapDirection.Left); } } if (input.PressedRightKey) { if (!director.PartyMoving) { MapEngine.MovePlayer(MapDirection.Right); } } // Action commands if (input.ConfirmKey) { // See if there's anyone in the direction to talk to if (MapEngine.CanTalk(out npcName, out dialogText)) { ScreenManager.AddScreen(new DialogBoxScreen(dialogText, DialogBoxScreen.DialogSpeed.Fast, DialogBoxScreen.DialogPlacement.Bottom)); } } }
/// <summary> /// Responds to user input, triggering on a button press. /// </summary> /// <param name="elapsed">Time passed since the last update in milliseconds</param> public override void HandleInput(InputState input, int elapsed) { // If the dialog is timed, don't handle inputs if (dialogTimed) { // If the text is complete, wait the duration specified if (textComplete) { dialogTimer += elapsed; if (dialogTimer >= dialogDuration) { // Remove the current message from the list and get the next one // If there's no next message, then this current dialog has ended messageList.RemoveAt(0); if (messageList.Count == 0) { // If we're using the dialogList, see if we can get the next dialog if ( (!usingMessageList && !GetNextDialog()) || usingMessageList) ExitScreen(); } GetNextMessage(); dialogTimer = 0; } } } else { if (input.IsNewKeyPress(ChronosSetting.ConfirmKey)) { // Mark that the button has bee pressed. Under draw, the text will either // display fully (if still in the process) or continue if (textComplete) { // Remove the current message from the list and get the next one // If there's no next message, then this current dialog has ended messageList.RemoveAt(0); if (messageList.Count == 0) { // If we're using the dialogList, see if we can get the next dialog if ((!usingMessageList && !GetNextDialog()) || usingMessageList) ExitScreen(); } GetNextMessage(); } else { textComplete = true; } } } }
/// <summary> /// Handles input and used for controlling specific parameters for debugging /// </summary> /// <param name="input">Input from the keyboard</param> /// <param name="elapsed">Time different from last update in seconds</param> public static void processInput(InputState input, float elapsed) { // DEBUG CONTROLS if (DebugOn) { // Toggle status message display if (input.IsNewKeyPress(Keys.NumPad5)) { BattleDebug.ShowStatusMsg = !BattleDebug.ShowStatusMsg; BattleDebug.Add("[5] Toggling Status Display"); } } }
/// <summary> /// Handles input and used for controlling specific parameters for debugging /// </summary> /// <param name="input">Input from the keyboard</param> /// <param name="elapsed">Time different from last update</param> public static void processInput(InputState input, float elapsed) { // DEBUG CONTROLS if (DebugOn) { // Handles inputs for controlling the camera if (ControlCamera) { //Set the camera's state to Unchanged for this frame //this will save us from having to update visibility if the camera //does not move ResetCameraChange(); // Otherwise move the camera Vector2 movement = Vector2.Zero; // Check for camera movement float dX = input.ReadKeyboardAxis(PlayerIndex.One, Keys.Left, Keys.Right) * elapsed * cMovementRate; float dY = input.ReadKeyboardAxis(PlayerIndex.One, Keys.Down, Keys.Up) * elapsed * cMovementRate; MoveCamera(AxisType.XAxis, ref dX); MoveCamera(AxisType.YAxis, ref dY); //check for camera rotation dX = input.ReadKeyboardAxis(PlayerIndex.One, Keys.E, Keys.Q) * elapsed * cRotationRate; RotateCamera(ref dX); //check for camera zoom dX = input.ReadKeyboardAxis(PlayerIndex.One, Keys.X, Keys.Z) * elapsed * cZoomRate; MoveCamera(AxisType.ZAxis, ref dX); } // Toggles visibility for the layers if (input.IsNewKeyPress(Keys.NumPad0)) { ShowLayer[0] = !ShowLayer[0]; MapDebug.Add("[0] Toggling Bottom Layer"); } if (input.IsNewKeyPress(Keys.NumPad1)) { ShowLayer[1] = !ShowLayer[1]; MapDebug.Add("[1] Toggling Middle Layer"); } if (input.IsNewKeyPress(Keys.NumPad2)) { ShowLayer[2] = !ShowLayer[2]; MapDebug.Add("[2] Toggling Top Layer"); } if (input.IsNewKeyPress(Keys.OemPeriod)) // Reset the layers { for (int i = 0; i < 3; i++) ShowLayer[i] = true; MapDebug.Add("[.] Resetting All Layers"); } // Toggle the ability to control the camera if (input.IsNewKeyPress(Keys.Divide)) { ControlCamera = !ControlCamera; MapDebug.Add("[/] Toggling Camera Control"); } // Toggle status message display if (input.IsNewKeyPress(Keys.NumPad5)) { MapDebug.ShowStatusMsg = !MapDebug.ShowStatusMsg; MapDebug.Add("[5] Toggling Status Display"); } // Reset the camera values if (input.IsNewKeyPress(Keys.Multiply)) { ResetToInitialPositions(); MapDebug.Add("[*] Resetting Camera Positions"); } } }