public override void HandleInput(Input.InputState input) { if (input.IsNewButtonPress(Buttons.Start) || input.IsNewKeyPress(Keys.Space) || input.IsNewKeyPress(Keys.Enter)) { if (fadeInTimer < 1f && !fadeOut) { fadeInTimer = 1f; } else if (!fadeOut) { fadeOut = true; select.Play(); } else { fadeInTimer = 0.0f; } } }
public override void handleInput(Input.InputState inputState) { if( currentState == State.Attacking ) return; if (currentState == State.Neutral && (inputState.IsNewButtonPress(Buttons.A) || inputState.IsNewKeyPress(Keys.Space))) { currentState = State.Attacking; attackState = AttackState.Diagonal; velocity = Vector2.Zero; stateTimer = 0; return; } if (currentState == State.Neutral) { velocity = inputState.currentGamePadState.ThumbSticks.Left; velocity.Y *= -1f; acceleration = Vector2.Zero; } else { acceleration = inputState.currentGamePadState.ThumbSticks.Left * 0.1f; acceleration.Y *= -1f; return; } if (velocity.X < 0f && Math.Abs(velocity.X) > Math.Abs(velocity.Y) ) { currentSourceRect = WalkingLeft; faceDir = FaceDirection.Left; } else if (velocity.X > 0f && Math.Abs(velocity.X) > Math.Abs(velocity.Y)) { currentSourceRect = WalkingRight; faceDir = FaceDirection.Right; } else if (velocity.Y < 0f ) { currentSourceRect = WalkingUp; faceDir = FaceDirection.Up; } else if (velocity.Y > 0f) { currentSourceRect = WalkingDown; faceDir = FaceDirection.Down; } if (Keyboard.GetState().GetPressedKeys().Length > 0) { velocity = Vector2.Zero; if( inputState.currentKeyboardState.IsKeyDown(Keys.W) ) { currentSourceRect = WalkingUp; faceDir = FaceDirection.Up; velocity.Y = -1; } if (inputState.currentKeyboardState.IsKeyDown(Keys.A)) { currentSourceRect = WalkingLeft; faceDir = FaceDirection.Left; velocity.X = -1; } if (inputState.currentKeyboardState.IsKeyDown(Keys.S)) { currentSourceRect = WalkingDown; faceDir = FaceDirection.Down; velocity.Y = 1; } if (inputState.currentKeyboardState.IsKeyDown(Keys.D)) { currentSourceRect = WalkingRight; faceDir = FaceDirection.Right; velocity.X = 1; } if (velocity != Vector2.Zero) velocity.Normalize(); } //velocity.Normalize(); velocity *= maxSpeed; animSpeed = velocity.Length() / 18f; }