Example #1
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input, int elapsed)
        {
            // If the selected rows or column isn't valid, then there's no visible menu
            // to select from, so skip the inputs
            if (selectedColEntry == -1 || selectedRowEntry == -1)
                return;

            // Move up menu entry?
            if (input.UpKey)
            {
                do
                {
                    selectedRowEntry--;

                    if (selectedRowEntry < 0)
                        selectedRowEntry = menuEntries[selectedColEntry].Count - 1;
                } while (menuEntries[selectedColEntry][selectedRowEntry].ShowMe == false ||
                    menuEntries[selectedColEntry][selectedRowEntry].IsActive == false);
            }

            // Move down menu entry?
            if (input.DownKey)
            {
                do
                {
                    selectedRowEntry++;

                    if (selectedRowEntry >= menuEntries[selectedColEntry].Count)
                        selectedRowEntry = 0;
                }while(menuEntries[selectedColEntry][selectedRowEntry].ShowMe == false ||
                    menuEntries[selectedColEntry][selectedRowEntry].IsActive == false);
            }

            // Move to the left menu entry?
            if (input.LeftKey)
            {
                // Do an additional check to see if there's menu entry to select
                // If not, keep advancing left until we hit one
                do
                {
                    selectedColEntry--;

                    if (selectedColEntry < 0)
                        selectedColEntry = ChronoConstants.cMaxMenus - 1;

                } while (menuEntries[selectedColEntry].Count == 0 ||
                    !isMenuVisible[selectedColEntry] ||
                    menuEntries[selectedColEntry][selectedRowEntry].ShowMe == false ||
                    menuEntries[selectedColEntry][selectedRowEntry].IsActive == false);
            }

            // Move to the right menu entry?
            if (input.RightKey)
            {
                // Do an additional check to see if there's menu entry to select
                // If not, keep advancing right until we hit one
                do
                {
                    selectedColEntry++;

                    if (selectedColEntry >= ChronoConstants.cMaxMenus)
                        selectedColEntry = 0;

                } while (menuEntries[selectedColEntry].Count == 0 ||
                    !isMenuVisible[selectedColEntry] ||
                    menuEntries[selectedColEntry][selectedRowEntry].ShowMe == false ||
                    menuEntries[selectedColEntry][selectedRowEntry].IsActive == false);
            }

            // Accept the menu?  Note there's no cancel for this
            if (input.ConfirmKey)
            {
                OnSelectEntry(selectedRowEntry, selectedColEntry);
            }
            else if (input.CancelKey)
            {
                OnCancel();
            }
        }
Example #2
0
 /// <summary>
 /// Allows the screen to handle user input. Unlike Update, this method
 /// is only called when the screen is active, and not when some other
 /// screen has taken the focus.
 /// </summary>
 public virtual void HandleInput(InputState input, int elapsed)
 {
 }
        /// <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));
                }
            }
        }
Example #4
0
 /// <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>
        /// Responds to user input, accepting or cancelling the message box.
        /// </summary>
        public override void HandleInput(InputState input, int elapsed)
        {
            if (input.SelectKey)
            {
                // Raise the accepted event, then exit the message box.
                if (Accepted != null)
                    Accepted(this, EventArgs.Empty);

                ExitScreen();
            }
            else if (input.CancelKey)
            {
                // Raise the cancelled event, then exit the message box.
                if (Cancelled != null)
                    Cancelled(this, EventArgs.Empty);

                ExitScreen();
            }
        }
        /// <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;
                    }
                }
            }
        }
Example #7
0
 /// <summary>
 /// Grabs any recognized user input and exits the screen.
 /// </summary>
 /// <param name="elapsed">Time passed since the last update in milliseconds</param>
 public override void HandleInput(InputState input, int elapsed)
 {
     // Checks for any button presses
     if (input.CancelKey || input.ConfirmKey)
         ExitScreen();
 }
        /// <summary>
        /// Handles the input.
        /// </summary>
        /// <param name="input"></param>
        /// <param name="elapsed"></param>
        public override void HandleInput(InputState input, int elapsed)
        {
            // If we're selecting a target, handle it here.  Otherwise, handle menu commands
            if (selectingTarget)
            {
                // Cancel from selecting
                if (input.CancelKey)
                {
                    ResetBattleSelection();
                }

                // If target is selected, clear the menu and signal the attack handler
                if (input.ConfirmKey)
                {
                    // Reset the selected menu entry and flag
                    ResetSelected();
                    selectingTarget = false;

                    // Signal the handler
                    OnAttackSelected(characterSelecting, targetID);
                    characterSelecting = -1;
                    targetID = -1;
                }

                // Select the next target
                if (input.RightKey || input.DownKey)
                {
                    // If there's no enemy don't try to select anything
                    if (BattleEngine.EnemyAliveCount > 0)
                    {
                        // Keep cycling through the enemies until we reach on that is alive
                        do
                        {
                            targetID++;

                            // Bound check
                            if (targetID > BattleEngine.EnemyCount)
                                targetID = 0;

                        } while (!BattleEngine.IsEnemyAlive(targetID));
                    }
                }

                // Select the previous target
                if (input.LeftKey || input.UpKey)
                {
                    // If there's no enemy don't try to select anything
                    if (BattleEngine.EnemyAliveCount > 0)
                    {
                        // Keep cycling through the enemies until we reach on that is alive
                        do
                        {
                            targetID--;

                            // Bound check
                            if (targetID < 0)
                                targetID = BattleEngine.EnemyCount - 1;
                        } while (!BattleEngine.IsEnemyAlive(targetID) && BattleEngine.EnemyAliveCount > 0);
                    }
                }
            }
            else
                base.HandleInput(input, elapsed);
        }
Example #9
0
        /// <summary>
        /// Handles input presses and passes it to the appropriate function
        /// </summary>
        /// <param name="input">Input to recognize keyboard/gamepad commands</param>
        /// <param name="elapsed">Time passed since last update in milliseconds</param>
        public override void HandleInput(InputState input, int elapsed)
        {
            // If the battle is over don't handle inputs for the menu.  The inputs
            // should be routed to the new screen (displaying victory or death).
            if (!BattleEngine.BattleOver)
            {
                // BattleMenuScreen class will handle navigating the menu
                menuScreen.HandleInput(input, elapsed);
            }

            // Process input in the battle engine for debugging purposes
            BattleEngine.processInput(input, elapsed / (float)1000);
        }
Example #10
0
        /// <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");
                }
            }
        }