Esempio n. 1
0
        protected override void JumpCommandValidation()
        {
            JumpCommandArgs args = null;

            if (currentGamePadState.Buttons.A == ButtonState.Pressed &&
                previousGamePadState.Buttons.A == ButtonState.Released)
            {
                args = new JumpCommandArgs()
                {
                    From  = InputType.Keyboard,
                    State = CommandState.Started
                };

                if (currentGamePadState.DPad.Down == ButtonState.Pressed ||
                    currentGamePadState.IsButtonDown(Buttons.LeftThumbstickDown))
                {
                    args.InitialBoostDirection = VerticalDirection.Down;
                }
                else
                {
                    args.InitialBoostDirection = VerticalDirection.Up;
                }
            }
            else if (currentGamePadState.Buttons.A == ButtonState.Pressed)
            {
                args = new JumpCommandArgs()
                {
                    From  = InputType.Keyboard,
                    State = CommandState.Happening
                };
            }
            else if (currentGamePadState.Buttons.A == ButtonState.Released &&
                     previousGamePadState.Buttons.A == ButtonState.Pressed)
            {
                args = new JumpCommandArgs()
                {
                    From  = InputType.Keyboard,
                    State = CommandState.Ended
                };
            }

            if (args != null)
            {
                onJumpCommand?.Invoke(this, args);
            }
        }
Esempio n. 2
0
        protected override void JumpCommandValidation()
        {
            JumpCommandArgs args = null;

            if (currentKeyboardState.IsKeyDown(selectKey) &&
                previousKeyboardState.IsKeyUp(selectKey))
            {
                args = new JumpCommandArgs()
                {
                    From  = InputType.Keyboard,
                    State = CommandState.Started
                };

                args.InitialBoostDirection = currentKeyboardState.IsKeyDown(downKey) ?
                                             VerticalDirection.Down : VerticalDirection.Up;
            }
            else if (currentKeyboardState.IsKeyDown(selectKey))
            {
                args = new JumpCommandArgs()
                {
                    From  = InputType.Keyboard,
                    State = CommandState.Happening
                };
            }
            else if (currentKeyboardState.IsKeyUp(selectKey) &&
                     previousKeyboardState.IsKeyDown(selectKey))
            {
                args = new JumpCommandArgs()
                {
                    From  = InputType.Keyboard,
                    State = CommandState.Ended
                };
            }

            if (args != null)
            {
                onJumpCommand?.Invoke(this, args);
            }
        }