예제 #1
0
        public static InputStates getStatesFromKeys(KeyboardState keys, GamePadState pad, GamePadThumbSticks sticks)
        {
            var inputStates = ret;

            ret.movement = keys.IsKeyDown(Keys.Right) || pad.DPad.Right == ButtonState.Pressed
                ? 1f
                : (keys.IsKeyDown(Keys.Left) || pad.DPad.Left == ButtonState.Pressed
                    ? -1f
                    : sticks.Left.X == 0.0 ? 0.0f : sticks.Left.X);
            var buttons1 = pad.Buttons;

            ret.jumping = buttons1.A == ButtonState.Pressed || keys.IsKeyDown(Keys.Up);
            var buttons2 = pad.Buttons;

            ret.useItem   = buttons2.B == ButtonState.Pressed || keys.IsKeyDown(Keys.RightShift);
            ret.wmovement = keys.IsKeyDown(Keys.D) || pad.DPad.Right == ButtonState.Pressed
                ? 1f
                : (keys.IsKeyDown(Keys.A) || pad.DPad.Left == ButtonState.Pressed
                    ? -1f
                    : sticks.Left.X == 0.0 ? 0.0f : sticks.Left.X);
            ret.wjumping = pad.Buttons.A == ButtonState.Pressed || keys.IsKeyDown(Keys.W) || keys.IsKeyDown(Keys.Space) ||
                           pad.Triggers.Left > 0.0;
            var buttons3 = pad.Buttons;

            ret.wuseItem        = buttons3.B == ButtonState.Pressed || keys.IsKeyDown(Keys.LeftShift);
            lastCalculatedState = ret;
            return(ret);
        }
예제 #2
0
 public static InputStates getStatesFromKeys(KeyboardState keys, GamePadState pad, GamePadThumbSticks sticks)
 {
     var inputStates = ret;
     ret.movement = keys.IsKeyDown(Keys.Right) || pad.DPad.Right == ButtonState.Pressed
         ? 1f
         : (keys.IsKeyDown(Keys.Left) || pad.DPad.Left == ButtonState.Pressed
             ? -1f
             : sticks.Left.X == 0.0 ? 0.0f : sticks.Left.X);
     var buttons1 = pad.Buttons;
     ret.jumping = buttons1.A == ButtonState.Pressed || keys.IsKeyDown(Keys.Up);
     var buttons2 = pad.Buttons;
     ret.useItem = buttons2.B == ButtonState.Pressed || keys.IsKeyDown(Keys.RightShift);
     ret.wmovement = keys.IsKeyDown(Keys.D) || pad.DPad.Right == ButtonState.Pressed
         ? 1f
         : (keys.IsKeyDown(Keys.A) || pad.DPad.Left == ButtonState.Pressed
             ? -1f
             : sticks.Left.X == 0.0 ? 0.0f : sticks.Left.X);
     ret.wjumping = pad.Buttons.A == ButtonState.Pressed || keys.IsKeyDown(Keys.W) || keys.IsKeyDown(Keys.Space) ||
                    pad.Triggers.Left > 0.0;
     var buttons3 = pad.Buttons;
     ret.wuseItem = buttons3.B == ButtonState.Pressed || keys.IsKeyDown(Keys.LeftShift);
     lastCalculatedState = ret;
     return ret;
 }