public override void HandleButton(InputButton button, InputButtonState state, Player0 player) { if (state == InputButtonState.Pressed) { // opposite direction was pressed while moving, freeze if (button == InputButton.Left || button == InputButton.Right) { Freeze = true; } } else if (state == InputButtonState.Released) { if (button == InputButton.Right || button == InputButton.Left) { if (Freeze) { Direction = new Vector2f(button == InputButton.Right ? -1 : 1, Direction.Y); Freeze = false; } else { player.ChangeMovement(new Crouching()); } } else if (button == Settings.Instance.InputMappings.Crouch) { player.ChangeMovement(new Walking(this)); } } }
public override void HandleButton(InputButton button, InputButtonState state, Player0 player) { if (state == InputButtonState.Released) { if (button == Settings.Instance.InputMappings.Crouch) { player.ChangeMovement(new Falling(this), false); } else if (button == InputButton.Left || button == InputButton.Right) { if (Freeze) { // player should continue moving in the one that is still pressed Direction = new Vector2f(button == InputButton.Right ? -1 : 1, Direction.Y); Freeze = false; player.AddMovement(new Walking(this)); } else { Direction = new Vector2f(0, Direction.Y); player.AddMovement(new Idle()); } } } }
public override void HandleButton(InputButton button, InputButtonState state, Player0 player) { if (state == InputButtonState.Released) { if (button == Settings.Instance.InputMappings.Crouch) { player.ChangeMovement(new Idle()); } } else if (state == InputButtonState.Pressed) { if (button == InputButton.Left || button == InputButton.Right) { player.ChangeMovement(new Sneaking(button)); } } }
public override void Update(Player0 player) { base.Update(player); // nothing to do player.Velocity = Vector2f.Zero; if (!player.ObstacleAt(Side.Down)) { player.ChangeMovement(new Falling()); } }
public override void Update(Player0 player) { base.Update(player); if (!player.ObstacleAt(Side.Down)) { player.ChangeMovement(new Falling(this)); } else { player.Velocity.X = Freeze ? 0 : Direction.X * WalkingStep; } }
public override void HandleButton(InputButton button, InputButtonState state, Player0 player) { if (state == InputButtonState.Pressed) { // if direction was changed in air if (button == InputButton.Left || button == InputButton.Right) { // if opposite direction is pressed if ((button == InputButton.Left && Direction.X > 0) || (button == InputButton.Right && Direction.X < 0)) { Freeze = true; player.AddMovement(new Walking(this)); } else { // set new direction Direction = new Vector2f(button == InputButton.Right ? 1 : -1, Direction.Y); player.AddMovement(new Walking(this)); } } else if (button == Settings.Instance.InputMappings.Crouch) { player.ChangeMovement(new Diving(this), false); } } else if (state == InputButtonState.Released) { if (button == InputButton.Left || button == InputButton.Right) { if (Freeze) { // player should continue moving in the one that is still pressed Direction = new Vector2f(button == InputButton.Right ? -1 : 1, Direction.Y); Freeze = false; player.AddMovement(new Walking(this)); } else { Direction = new Vector2f(0, Direction.Y); player.AddMovement(new Idle()); } } } }
public override void HandleButton(InputButton button, InputButtonState state, Player0 player) { if (state == InputButtonState.Pressed) { // if direction was changed in air if (button == InputButton.Left || button == InputButton.Right) { // if opposite direction is pressed if ((button == InputButton.Left && Direction.X > 0) || (button == InputButton.Right && Direction.X < 0)) { Freeze = true; player.AddMovement(new Walking(this)); } else { // set new direction Direction = new Vector2f(button == InputButton.Right ? 1 : -1, Direction.Y); player.AddMovement(new Walking(Direction)); } } else if (button == Settings.Instance.InputMappings.Crouch) { player.ChangeMovement(new Diving(this), false); } else if (button == Settings.Instance.InputMappings.Jump) { if (ExtraJump > 0) { ExtraJump--; Jump = new Vector2f(0, JumpImpulse * DoubleJumpMultiplier); } } else if (button == Settings.Instance.InputMappings.Dash) { if (!Freeze && Math.Abs(Direction.X) > 0) { player.ChangeMovement(new Dashing(this), false); } } } else if (state == InputButtonState.Released) { if (button == InputButton.Right || button == InputButton.Left) { if (Freeze) { // player should continue moving in the one that is still pressed Direction = new Vector2f(button == InputButton.Right ? -1 : 1, Direction.Y); Freeze = false; player.AddMovement(new Walking(Direction)); } else { Direction = new Vector2f(0, Direction.Y); player.AddMovement(new Idle()); } } else if (button == Settings.Instance.InputMappings.Jump) { if (player.Velocity.Y > 0) { player.Velocity.Y = 0.0; } } else if (button == Settings.Instance.InputMappings.Run) { RunMultiplier = 1.0; player.AddMovement(new Walking(this)); } } }