public InputData checkKeyboardaswd() // check input aswd { iOption <CharacterMovementAction> MoveAction = new None <CharacterMovementAction>(); iOption <WalkDirectionInput> WalkDirection = new None <WalkDirectionInput>(); iOption <CharacterActivity> CharacterActivity = new None <CharacterActivity>(); iOption <SettingsInput> Settings = new None <SettingsInput>(); iOption <MousePressed> MouseAction = new None <MousePressed>(); Toilet_time_main.Point cursor = new Toilet_time_main.Point(-1, -1); KeyboardState keyboard_state = Keyboard.GetState(); var mouse_state = Mouse.GetState(); cursor = new Toilet_time_main.Point(mouse_state.X, mouse_state.Y); current_cursor = cursor; if (mouse_state.LeftButton == ButtonState.Pressed) { MouseAction = new Some <MousePressed>(MousePressed.Left_Button); } if (keyboard_state.IsKeyDown(Keys.W)) { MoveAction = new Some <CharacterMovementAction>(CharacterMovementAction.Jump); } if (keyboard_state.IsKeyDown(Keys.A)) { WalkDirection = new Some <WalkDirectionInput>(WalkDirectionInput.Left); } if (keyboard_state.IsKeyDown(Keys.D)) { WalkDirection = new Some <WalkDirectionInput>(WalkDirectionInput.Right); } if (keyboard_state.IsKeyDown(Keys.A) && keyboard_state.IsKeyDown(Keys.D)) { WalkDirection = new None <WalkDirectionInput>(); } if (keyboard_state.IsKeyDown(Keys.E)) { CharacterActivity = new Some <CharacterActivity>(Toilet_time_main.CharacterActivity.Action); } return(new InputData(MoveAction, WalkDirection, CharacterActivity, Settings, MouseAction, cursor, GamepadOnline)); }
public void DrawCursor(Toilet_time_main.Point mousepoint) { // spritebatch.Draw(Texture_Mouse, ConvertRectangle(new Rectangle(mousepoint.x - 3, mousepoint.y - 3, 25, 25)), Color.White); }
public InputData checkGamePad() // check input by gamepad { iOption <CharacterMovementAction> MoveAction = new None <CharacterMovementAction>(); iOption <WalkDirectionInput> WalkDirection = new None <WalkDirectionInput>(); iOption <CharacterActivity> CharacterActivity = new None <CharacterActivity>(); iOption <SettingsInput> Settings = new None <SettingsInput>(); iOption <MousePressed> MouseAction = new None <MousePressed>(); float Mousesensitivity = 8f; Toilet_time_main.Point ReturnCursor = current_cursor; KeyboardState keyboard_state = Keyboard.GetState(); GamePadState gamePadState = GamePad.GetState(PlayerIndex.One); if (gamePadState.IsConnected) { // then it is connected, and we can do stuff here //Walk if (gamePadState.ThumbSticks.Left.X < -0.1) { WalkDirection = new Some <WalkDirectionInput>(WalkDirectionInput.Left); } else if (gamePadState.ThumbSticks.Left.X > 0.1) { WalkDirection = new Some <WalkDirectionInput>(WalkDirectionInput.Right); } // Move cursor if (gamePadState.ThumbSticks.Right.X < -0.1) { ReturnCursor.x = ReturnCursor.x - (int)(-1 * gamePadState.ThumbSticks.Right.X * Mousesensitivity); } else if (gamePadState.ThumbSticks.Right.X > -0.1) { ReturnCursor.x = ReturnCursor.x + (int)(gamePadState.ThumbSticks.Right.X * Mousesensitivity); } if (gamePadState.ThumbSticks.Right.Y < -0.1) { ReturnCursor.y = ReturnCursor.y + (int)(-1 * gamePadState.ThumbSticks.Right.Y * Mousesensitivity); } else if (gamePadState.ThumbSticks.Right.Y > -0.1) { ReturnCursor.y = ReturnCursor.y - (int)(gamePadState.ThumbSticks.Right.Y * Mousesensitivity); } if (gamePadState.Buttons.A == ButtonState.Pressed) { MouseAction = new Some <MousePressed>(MousePressed.Left_Button); MoveAction = new Some <CharacterMovementAction>(CharacterMovementAction.Jump); } if (gamePadState.Buttons.B == ButtonState.Pressed) { CharacterActivity = new Some <CharacterActivity>(Toilet_time_main.CharacterActivity.Action); } Toilet_time_main.Point cursor = ReturnCursor; return(new InputData(MoveAction, WalkDirection, CharacterActivity, Settings, MouseAction, cursor, GamepadOnline)); } else { return(checkKeyboardpijltjes()); // returns input of checkkeyboardpijltjes when controller disconnects } //return new Input(); }