public override void LogicUpdate()
    {
        base.LogicUpdate();
        if (isExitingState)
        {
            return;
        }

        if (_jumpInput && _isHolding && IsGrounded)
        {
            SwordCharacter.RB.drag = 0;
            SwordCharacter.SetVelocityAngular(SwordCharacterData.DashJumpVelocity, SwordCharacterData.DashJumpAngle, SwordCharacter.FacingDirection);
        }

        if (_isHolding && IsGrounded)
        {
            _dashInputStop = SwordCharacter.InputHandler.DashInputStop;
            if (_dashInputStop)
            {
                _isHolding = false;
            }
            SwordCharacter.RB.drag = SwordCharacterData.Drag;
            SwordCharacter.CheckIfShouldFlip(XInput);
            SwordCharacter.SetVelocityX(SwordCharacterData.DashVelocity * SwordCharacter.FacingDirection);
        }

        if (!_isHolding || !IsGrounded || Time.time >= startTime + SwordCharacterData.DashTimeDistance)
        {
            SwordCharacter.RB.drag = 0;
            IsAbilityDone          = true;
            _lastDashTime          = Time.time;
        }
    }
    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));
        }
    }
Beispiel #3
0
    public override void LogicUpdate()
    {
        base.LogicUpdate();

        SwordCharacter.CheckIfShouldFlip(XInput);
        SwordCharacter.SetVelocityX(SwordCharacterData.MovementVelocity * XInput);
        if (isExitingState)
        {
            return;
        }
        if (XInput == 0)
        {
            SwordCharaterStateMachine.ChangeState(SwordCharacter.IdleState);
        }
    }
 public override void Enter()
 {
     base.Enter();
     SwordCharacter.SetVelocityX(0f);
 }