コード例 #1
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());
                    }
                }
            }
        }
コード例 #2
0
        public override void HandleButton(InputButton button, InputButtonState state, Player0 player)
        {
            // dashing is uncontrollable
            if (state == InputButtonState.Released)
            {
                if ((button == InputButton.Right && Direction.X > 0) || (button == InputButton.Left && Direction.X < 0))
                {
                    player.AddMovement(new Idle());
                }

                else if (button == Settings.Instance.InputMappings.Run)
                {
                    player.AddMovement(new Walking(Direction.Normalize()));
                }
            }
        }
コード例 #3
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());
                    }
                }
            }
        }
コード例 #4
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));
                }
            }
        }