public override void LogicUpdate()
    {
        base.LogicUpdate();
        CheckCoyoteTime();
        _xInput        = SwordCharacter.InputHandler.InputX;
        _jumpInput     = SwordCharacter.InputHandler.JumpInput;
        _jumpInputStop = SwordCharacter.InputHandler.JumpInputStop;
        _grabInput     = SwordCharacter.InputHandler.GrabInput;
        _dashInput     = SwordCharacter.InputHandler.DashInput;

        CheckJumpMultiplier();

        if (_isGrounded && SwordCharacter.CurrentVelocity.y < 0.01f)
        {
            SwordCharaterStateMachine.ChangeState(SwordCharacter.LandState);
        }
        else if ((_isTouchingWall || _isTouchingGrabbable) && !_isTouchingWallAbove && !_isTouchingGrabbableAbove && !_isGrounded)
        {
            SwordCharaterStateMachine.ChangeState(SwordCharacter.LedgeCLimbState);
        }
        else if (SwordCharacterData.canWallJump && _jumpInput && _xInput == SwordCharacter.FacingDirection && (_isTouchingWall || _isTouchingGrabbable || _isTouchingWallBack))
        {
            _isTouchingWall      = SwordCharacter.CheckIfTouchingWall(); //update info in Update to increase accuracy
            _isTouchingGrabbable = SwordCharacter.CheckIfIsGrabbable();
            SwordCharacter.WallJumpState.CheckWallJumpDirection(_isTouchingGrabbable || _isTouchingWall);
            SwordCharaterStateMachine.ChangeState(SwordCharacter.WallJumpState);
        }
        else if (SwordCharacterData.canDoubleJump && _jumpInput && SwordCharacter.JumpState.CanJump())
        {
            SwordCharacter.Anim.SetTrigger("isDoubleJumpTrigger");
            SwordCharaterStateMachine.ChangeState(SwordCharacter.JumpState);
        }
        else if (_isTouchingGrabbable && _grabInput && _isTouchingGrabbableAbove)
        {
            SwordCharaterStateMachine.ChangeState(SwordCharacter.WallGrabState);
        }
        else if ((_isTouchingWall || _isTouchingGrabbable) && _xInput == SwordCharacter.FacingDirection && SwordCharacter.CurrentVelocity.y <= 0 && SwordCharacterData.canSlide)
        {
            SwordCharaterStateMachine.ChangeState(SwordCharacter.WallSlideState);
        }
        else if (_dashInput && SwordCharacter.AirDashState.CheckIfCanDash())
        {
            SwordCharaterStateMachine.ChangeState(SwordCharacter.AirDashState);
        }
        else
        {
            SwordCharacter.CheckIfShouldFlip(_xInput);
            SwordCharacter.SetVelocityX(SwordCharacterData.MovementVelocity * _xInput);
            SwordCharacter.Anim.SetFloat("yVelocity", SwordCharacter.CurrentVelocity.y);
            SwordCharacter.Anim.SetFloat("xVelocity", Mathf.Abs(SwordCharacter.CurrentVelocity.x));
        }
    }
示例#2
0
    public override void DoChecks()
    {
        base.DoChecks();
        IsGrounded               = SwordCharacter.CheckIfTouchingGround();
        IsTouchingWall           = SwordCharacter.CheckIfTouchingWall();
        IsTouchingWallAbove      = SwordCharacter.CheckIfTouchingWallAbove();
        IsTouchingGrabbable      = SwordCharacter.CheckIfIsGrabbable();
        IsTouchingGrabbableAbove = SwordCharacter.CheckIfTouchingGrabbableAbove();

        if ((IsTouchingWall || IsTouchingGrabbable) && !IsTouchingWallAbove && !IsTouchingGrabbableAbove)
        {
            SwordCharacter.LedgeCLimbState.SetDetectedPosition(SwordCharacter.transform.position);
        }
    }
 public override void DoChecks()
 {
     base.DoChecks();
     IsGrounded     = SwordCharacter.CheckIfTouchingGround();
     IsTouchingWall = SwordCharacter.CheckIfTouchingWall();
 }