public void HandleInput(KeyboardState state) { if (!_keyLocker.KeyPressed && state.IsKeyDown(Keys.Space) && !oldState.IsKeyDown(Keys.Space)) { // Change to JumpAction _actionStateMachine.Change("jump"); _keyLocker.LockKey(Keys.Space); } else if (state.IsKeyDown(Keys.Left) || state.IsKeyDown(Keys.Right)) // If left or right key is pressed { _actionStateMachine.Change("move"); } else if (!_keyLocker.KeyPressed && state.IsKeyDown(Keys.Z) && !oldState.IsKeyDown(Keys.Z)) { _actionStateMachine.Change("attack"); _keyLocker.LockKey(Keys.Z); } else if (oldState.IsKeyUp(Keys.X) && state.IsKeyDown(Keys.X)) { // Change to ThrowAction if actor is currently not throwing if (!_actor.isThrowing) { _actionStateMachine.Change("throw", "stand"); } } else if (state.IsKeyDown(Keys.Down)) { _actionStateMachine.Change("crouch"); } _keyLocker.CheckInputLock(state, Keys.Space); _keyLocker.CheckInputLock(state, Keys.Z); oldState = state; }
public void HandleInput(KeyboardState state) { handleViewPortMovement(state); // Check if we can press the specified key again keyLocker.CheckInputLock(state, Keys.Enter); keyLocker.CheckInputLock(state, Keys.Escape); keyLocker.CheckInputLock(state, Keys.I); // set the oldstate as the current state to prepare for the next state oldState = state; }