Exemple #1
0
 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));
         }
     }
 }
Exemple #2
0
        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());
                    }
                }
            }
        }
Exemple #3
0
 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));
         }
     }
 }
Exemple #4
0
        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());
            }
        }
Exemple #5
0
        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;
            }
        }
Exemple #6
0
        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());
                    }
                }
            }
        }
Exemple #7
0
        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));
                }
            }
        }