예제 #1
0
        public bool Down(InputDetectionType detectionType, DirectionalInputTypes inputTypes)
        {
            // todo: for all directions: check if game is active!

            if (inputTypes.HasFlag(DirectionalInputTypes.ScrollWheel) && Mouse.GetScrollWheelDifference() < 0)
            {
                return(true);
            }
            else if (inputTypes != DirectionalInputTypes.ScrollWheel) // when it's only scroll wheel, do not check the rest.
            {
                return(CheckDirectional(detectionType, InputDirection.Down, inputTypes, Keys.Down, Keys.S, Buttons.LeftThumbstickDown, Buttons.RightThumbstickDown, Buttons.DPadDown));
            }
            return(false);
        }
예제 #2
0
 private bool CheckDirectional(InputDetectionType detectionType, InputDirection direction, DirectionalInputTypes inputTypes,
                                      Keys arrowKey, Keys WASDKey, Buttons leftThumbstick, Buttons rightThumbstick, Buttons dPadDirection)
 {
     switch (detectionType)
     {
         case InputDetectionType.PressedOnce:
             return CheckDirectionalPressedOnce(direction, inputTypes, arrowKey, WASDKey, leftThumbstick, rightThumbstick, dPadDirection);
         case InputDetectionType.HeldDown:
             return CheckDirectionalHeldDown(inputTypes, arrowKey, WASDKey, leftThumbstick, rightThumbstick, dPadDirection);
         case InputDetectionType.Released:
             return CheckDirectionalReleased(inputTypes, arrowKey, WASDKey, leftThumbstick, rightThumbstick, dPadDirection);
     }
     return false;
 }
예제 #3
0
        private bool CheckDirectionalReleased(DirectionalInputTypes inputTypes,
                                              Keys arrowKey, Keys WASDKey, Buttons leftThumbstick, Buttons rightThumbstick, Buttons dPadDirection)
        {
            if (inputTypes.HasFlag(DirectionalInputTypes.ArrowKeys))
            {
                if (Keyboard.IsKeyUp(arrowKey))
                {
                    return(true);
                }
            }
            if (inputTypes.HasFlag(DirectionalInputTypes.WASD))
            {
                if (Keyboard.IsKeyUp(WASDKey))
                {
                    return(true);
                }
            }
            if (inputTypes.HasFlag(DirectionalInputTypes.LeftThumbstick))
            {
                if (GamePad.IsButtonUp(leftThumbstick))
                {
                    return(true);
                }
            }
            if (inputTypes.HasFlag(DirectionalInputTypes.RightThumbstick))
            {
                if (GamePad.IsButtonUp(rightThumbstick))
                {
                    return(true);
                }
            }
            if (inputTypes.HasFlag(DirectionalInputTypes.DPad))
            {
                if (GamePad.IsButtonUp(dPadDirection))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #4
0
        private bool CheckDirectionalPressedOnce(InputDirection direction, DirectionalInputTypes inputTypes,
                                                 Keys arrowKey, Keys WASDKey, Buttons leftThumbstick, Buttons rightThumbstick, Buttons dPadDirection)
        {
            bool hasAnyCommand = false;

            if (inputTypes.HasFlag(DirectionalInputTypes.WASD))
            {
                if (Keyboard.IsKeyDown(WASDKey))
                {
                    hasAnyCommand = true;
                    if (HoldDownPress(direction))
                    {
                        return(true);
                    }
                    else
                    {
                        if (Keyboard.IsKeyDownOnce(WASDKey))
                        {
                            ChangePressedDirection(direction);
                            return(true);
                        }
                    }
                }
            }
            if (inputTypes.HasFlag(DirectionalInputTypes.ArrowKeys))
            {
                if (Keyboard.IsKeyDown(arrowKey))
                {
                    hasAnyCommand = true;
                    if (HoldDownPress(direction))
                    {
                        return(true);
                    }
                    else
                    {
                        if (Keyboard.IsKeyDownOnce(arrowKey))
                        {
                            ChangePressedDirection(direction);
                            return(true);
                        }
                    }
                }
            }
            if (inputTypes.HasFlag(DirectionalInputTypes.LeftThumbstick))
            {
                if (GamePad.IsButtonDown(leftThumbstick))
                {
                    hasAnyCommand = true;
                    if (HoldDownPress(direction))
                    {
                        return(true);
                    }
                    else
                    {
                        if (GamePad.IsButtonDownOnce(leftThumbstick))
                        {
                            ChangePressedDirection(direction);
                            return(true);
                        }
                    }
                }
            }
            if (inputTypes.HasFlag(DirectionalInputTypes.RightThumbstick))
            {
                if (GamePad.IsButtonDown(rightThumbstick))
                {
                    hasAnyCommand = true;
                    if (HoldDownPress(direction))
                    {
                        return(true);
                    }
                    else
                    {
                        if (GamePad.IsButtonDownOnce(rightThumbstick))
                        {
                            ChangePressedDirection(direction);
                            return(true);
                        }
                    }
                }
            }
            if (inputTypes.HasFlag(DirectionalInputTypes.DPad))
            {
                if (GamePad.IsButtonDown(dPadDirection))
                {
                    hasAnyCommand = true;
                    if (HoldDownPress(direction))
                    {
                        return(true);
                    }
                    else
                    {
                        if (GamePad.IsButtonDownOnce(dPadDirection))
                        {
                            ChangePressedDirection(direction);
                            return(true);
                        }
                    }
                }
            }

            if (!hasAnyCommand)
            {
                ResetPressedDirection(direction);
            }

            return(false);
        }
예제 #5
0
        private bool CheckDirectional(InputDetectionType detectionType, InputDirection direction, DirectionalInputTypes inputTypes,
                                      Keys arrowKey, Keys WASDKey, Buttons leftThumbstick, Buttons rightThumbstick, Buttons dPadDirection)
        {
            switch (detectionType)
            {
            case InputDetectionType.PressedOnce:
                return(CheckDirectionalPressedOnce(direction, inputTypes, arrowKey, WASDKey, leftThumbstick, rightThumbstick, dPadDirection));

            case InputDetectionType.HeldDown:
                return(CheckDirectionalHeldDown(inputTypes, arrowKey, WASDKey, leftThumbstick, rightThumbstick, dPadDirection));

            case InputDetectionType.Released:
                return(CheckDirectionalReleased(inputTypes, arrowKey, WASDKey, leftThumbstick, rightThumbstick, dPadDirection));
            }
            return(false);
        }
예제 #6
0
        private bool CheckDirectionalPressedOnce(InputDirection direction, DirectionalInputTypes inputTypes,
                                             Keys arrowKey, Keys WASDKey, Buttons leftThumbstick, Buttons rightThumbstick, Buttons dPadDirection)
        {
            bool hasAnyCommand = false;

            if (inputTypes.HasFlag(DirectionalInputTypes.WASD))
            {
                if (Keyboard.IsKeyDown(WASDKey))
                {
                    hasAnyCommand = true;
                    if (HoldDownPress(direction))
                    {
                        return true;
                    }
                    else
                    {
                        if (Keyboard.IsKeyDownOnce(WASDKey))
                        {
                            ChangePressedDirection(direction);
                            return true;
                        }
                    }
                }
            }
            if (inputTypes.HasFlag(DirectionalInputTypes.ArrowKeys))
            {
                if (Keyboard.IsKeyDown(arrowKey))
                {
                    hasAnyCommand = true;
                    if (HoldDownPress(direction))
                    {
                        return true;
                    }
                    else
                    {
                        if (Keyboard.IsKeyDownOnce(arrowKey))
                        {
                            ChangePressedDirection(direction);
                            return true;
                        }
                    }
                }
            }
            if (inputTypes.HasFlag(DirectionalInputTypes.LeftThumbstick))
            {
                if (GamePad.IsButtonDown(leftThumbstick))
                {
                    hasAnyCommand = true;
                    if (HoldDownPress(direction))
                    {
                        return true;
                    }
                    else
                    {
                        if (GamePad.IsButtonDownOnce(leftThumbstick))
                        {
                            ChangePressedDirection(direction);
                            return true;
                        }
                    }
                }
            }
            if (inputTypes.HasFlag(DirectionalInputTypes.RightThumbstick))
            {
                if (GamePad.IsButtonDown(rightThumbstick))
                {
                    hasAnyCommand = true;
                    if (HoldDownPress(direction))
                    {
                        return true;
                    }
                    else
                    {
                        if (GamePad.IsButtonDownOnce(rightThumbstick))
                        {
                            ChangePressedDirection(direction);
                            return true;
                        }
                    }
                }
            }
            if (inputTypes.HasFlag(DirectionalInputTypes.DPad))
            {
                if (GamePad.IsButtonDown(dPadDirection))
                {
                    hasAnyCommand = true;
                    if (HoldDownPress(direction))
                    {
                        return true;
                    }
                    else
                    {
                        if (GamePad.IsButtonDownOnce(dPadDirection))
                        {
                            ChangePressedDirection(direction);
                            return true;
                        }
                    }
                }
            }

            if (!hasAnyCommand)
                ResetPressedDirection(direction);

            return false;
        }
예제 #7
0
        public bool Down(InputDetectionType detectionType, DirectionalInputTypes inputTypes)
        {
            // todo: for all directions: check if game is active!

            if (inputTypes.HasFlag(DirectionalInputTypes.ScrollWheel) && Mouse.GetScrollWheelDifference() < 0)
            {
                return true;
            }
            else if (inputTypes != DirectionalInputTypes.ScrollWheel) // when it's only scroll wheel, do not check the rest.
            {
                return CheckDirectional(detectionType, InputDirection.Down, inputTypes, Keys.Down, Keys.S, Buttons.LeftThumbstickDown, Buttons.RightThumbstickDown, Buttons.DPadDown);
            }
            return false;
        }
예제 #8
0
        private bool CheckDirectionalReleased(DirectionalInputTypes inputTypes,
                                          Keys arrowKey, Keys WASDKey, Buttons leftThumbstick, Buttons rightThumbstick, Buttons dPadDirection)
        {
            if (inputTypes.HasFlag(DirectionalInputTypes.ArrowKeys))
                if (Keyboard.IsKeyUp(arrowKey)) return true;
            if (inputTypes.HasFlag(DirectionalInputTypes.WASD))
                if (Keyboard.IsKeyUp(WASDKey)) return true;
            if (inputTypes.HasFlag(DirectionalInputTypes.LeftThumbstick))
                if (GamePad.IsButtonUp(leftThumbstick)) return true;
            if (inputTypes.HasFlag(DirectionalInputTypes.RightThumbstick))
                if (GamePad.IsButtonUp(rightThumbstick)) return true;
            if (inputTypes.HasFlag(DirectionalInputTypes.DPad))
                if (GamePad.IsButtonUp(dPadDirection)) return true;

            return false;
        }