Exemple #1
0
 protected override void HandleInput(HashSet <KeyPress> input)
 {
     if (!CollisionCommon.IsGrounded(_player))
     {
         ChangeState(PlayerStateEnum.TestAirborneMove);
     }
     else if (input.Contains(KeyPress.Jump))
     {
         ChangeState(PlayerStateEnum.TestJump);
     }
     else if (input.Contains(KeyPress.Roll))
     {
         ChangeState(PlayerStateEnum.TestRoll);
     }
     else if (input.Contains(KeyPress.MidAttack))
     {
         ChangeState(PlayerStateEnum.TestMidAttack);
     }
     else if (input.Contains(KeyPress.MoveRight))
     {
         ChangeState(PlayerStateEnum.TestMove);
         AnimatorCommon.FaceRight(_animator);
     }
     else if (input.Contains(KeyPress.MoveLeft))
     {
         ChangeState(PlayerStateEnum.TestMove);
         AnimatorCommon.FaceLeft(_animator);
     }
 }
    void FixedUpdate()
    {
        int dir = (_controller.FacingRight()) ? 1 : -1;

        switch (_controller.GetState())
        {
        case PlayerStateEnum.TestMove:
        case PlayerStateEnum.TestAirborneMove:
            _rb.AddRelativeForce(transform.right * Constants.BASE_MOVE_SPEED * dir);
            break;

        case PlayerStateEnum.TestJump:
            if (CollisionCommon.IsGrounded(gameObject))
            {
                _rb.AddRelativeForce(transform.up * Constants.BASE_JUMP_SPEED);
            }
            break;

        case PlayerStateEnum.TestRoll:
            _rb.AddRelativeForce(transform.right * Constants.BASE_ROLL_SPEED * dir);
            break;
        }
    }
Exemple #3
0
 private bool IsGrounded()
 {
     return(CollisionCommon.IsGrounded(_player));
 }