/// <summary> /// Process movement input /// </summary> public void ProcessInput(float elapsedTime, InputState current, int player) { // camera rotation rotationForce.X = inputRotationForce * current.padState[player].ThumbSticks.Right.Y; rotationForce.Y = -inputRotationForce * current.padState[player].ThumbSticks.Right.X; rotationForce.Z = 0.0f; // camera bank if (current.padState[player].Buttons.RightShoulder == ButtonState.Pressed) rotationForce.Z += inputRotationForce; if (current.padState[player].Buttons.LeftShoulder == ButtonState.Pressed) rotationForce.Z -= inputRotationForce; // move forward/backward force.X = inputForce * current.padState[player].ThumbSticks.Left.X; if (current.padState[player].Buttons.RightStick == ButtonState.Pressed) { // slide up/down force.Y = inputForce * current.padState[player].ThumbSticks.Left.Y; force.Z = 0.0f; } else { // slide left/right force.Y = 0.0f; force.Z = inputForce * current.padState[player].ThumbSticks.Left.Y; } // keyboard camera rotation if (current.keyState[player].IsKeyDown(Keys.Up)) rotationForce.X = inputRotationForce; if (current.keyState[player].IsKeyDown(Keys.Down)) rotationForce.X = -inputRotationForce; if (current.keyState[player].IsKeyDown(Keys.Left)) rotationForce.Y = inputRotationForce; if (current.keyState[player].IsKeyDown(Keys.Right)) rotationForce.Y = -inputRotationForce; // keyboard camera bank if (current.keyState[player].IsKeyDown(Keys.A)) rotationForce.Z = -inputRotationForce; if (current.keyState[player].IsKeyDown(Keys.D)) rotationForce.Z = inputRotationForce; // move forward/backward if (current.keyState[player].IsKeyDown(Keys.W)) force.Z = inputForce; if (current.keyState[player].IsKeyDown(Keys.S)) force.Z = -inputForce; // slide left/right if (current.keyState[player].IsKeyDown(Keys.Q)) force.X = -inputForce; if (current.keyState[player].IsKeyDown(Keys.E)) force.X = inputForce; }
public void CopyInput(InputState state) { padState[0] = state.padState[0]; padState[1] = state.padState[1]; keyState[0] = state.keyState[0]; keyState[1] = state.keyState[1]; }
/// <summary> /// Process movement input /// </summary> public void ProcessInput(float elapsedTime, InputState current, int player) { // camera rotation rotationForce.X = inputRotationForce * current.padState[player].ThumbSticks.Right.Y; rotationForce.Y = -inputRotationForce * current.padState[player].ThumbSticks.Right.X; rotationForce.Z = 0.0f; // camera bank if (current.padState[player].Buttons.RightShoulder == ButtonState.Pressed) { rotationForce.Z += inputRotationForce; } if (current.padState[player].Buttons.LeftShoulder == ButtonState.Pressed) { rotationForce.Z -= inputRotationForce; } // move forward/backward force.X = inputForce * current.padState[player].ThumbSticks.Left.X; if (current.padState[player].Buttons.RightStick == ButtonState.Pressed) { // slide up/down force.Y = inputForce * current.padState[player].ThumbSticks.Left.Y; force.Z = 0.0f; } else { // slide left/right force.Y = 0.0f; force.Z = inputForce * current.padState[player].ThumbSticks.Left.Y; } // keyboard camera rotation if (current.keyState[player].IsKeyDown(Keys.Up)) { rotationForce.X = inputRotationForce; } if (current.keyState[player].IsKeyDown(Keys.Down)) { rotationForce.X = -inputRotationForce; } if (current.keyState[player].IsKeyDown(Keys.Left)) { rotationForce.Y = inputRotationForce; } if (current.keyState[player].IsKeyDown(Keys.Right)) { rotationForce.Y = -inputRotationForce; } // keyboard camera bank if (current.keyState[player].IsKeyDown(Keys.A)) { rotationForce.Z = -inputRotationForce; } if (current.keyState[player].IsKeyDown(Keys.D)) { rotationForce.Z = inputRotationForce; } // move forward/backward if (current.keyState[player].IsKeyDown(Keys.W)) { force.Z = inputForce; } if (current.keyState[player].IsKeyDown(Keys.S)) { force.Z = -inputForce; } // slide left/right if (current.keyState[player].IsKeyDown(Keys.Q)) { force.X = -inputForce; } if (current.keyState[player].IsKeyDown(Keys.E)) { force.X = inputForce; } }
InputState lastState; // last frame input #endregion Fields #region Constructors /// <summary> /// Create a new input manager /// </summary> public InputManager() { currentState = new InputState(); lastState = new InputState(); }