コード例 #1
0
 private static void ChangeDirectionPressed(PressDirections direction)
 {
     if (_lastPressedDirection != direction)
     {
         _pressedKeyDelay      = 4f;
         _lastPressedDirection = direction;
     }
 }
コード例 #2
0
 private static void ResetDirectionPressed(PressDirections direction)
 {
     if (_lastPressedDirection == direction)
     {
         _pressedKeyDelay      = 4f;
         _lastPressedDirection = PressDirections.None;
     }
 }
コード例 #3
0
 private static bool HoldDownPress(PressDirections direction)
 {
     if (_lastPressedDirection == direction)
     {
         _pressedKeyDelay -= 0.1f;
         if (_pressedKeyDelay <= 0f)
         {
             _pressedKeyDelay = 0.3f;
             return(true);
         }
     }
     return(false);
 }
コード例 #4
0
        private static bool CheckDirectionalPress(PressDirections direction, Keys wasdKey, Keys directionalKey, Buttons thumbStickDirection, Buttons dPadDirecion, bool arrowKeys, bool wasd, bool thumbStick, bool dPad)
        {
            bool command = false;

            if (wasd)
            {
                if (KeyBoardHandler.KeyDown(wasdKey))
                {
                    command = true;
                    if (HoldDownPress(direction))
                    {
                        return(true);
                    }
                    if (KeyBoardHandler.KeyPressed(wasdKey))
                    {
                        ChangeDirectionPressed(direction);
                        return(true);
                    }
                }
            }
            if (arrowKeys)
            {
                if (KeyBoardHandler.KeyDown(directionalKey))
                {
                    command = true;
                    if (HoldDownPress(direction))
                    {
                        return(true);
                    }
                    if (KeyBoardHandler.KeyPressed(directionalKey))
                    {
                        ChangeDirectionPressed(direction);
                        return(true);
                    }
                }
            }
            if (thumbStick)
            {
                if (ControllerHandler.ButtonDown(thumbStickDirection))
                {
                    command = true;
                    if (HoldDownPress(direction))
                    {
                        return(true);
                    }
                    if (ControllerHandler.ButtonPressed(thumbStickDirection))
                    {
                        ChangeDirectionPressed(direction);
                        return(true);
                    }
                }
            }
            if (dPad)
            {
                if (ControllerHandler.ButtonDown(dPadDirecion))
                {
                    command = true;
                    if (HoldDownPress(direction))
                    {
                        return(true);
                    }
                    if (ControllerHandler.ButtonPressed(dPadDirecion))
                    {
                        ChangeDirectionPressed(direction);
                        return(true);
                    }
                }
            }

            if (command == false)
            {
                ResetDirectionPressed(direction);
            }

            return(false);
        }