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;
        }
    }
示例#2
0
 public override void Enter()
 {
     base.Enter();
     SwordCharacter.InputHandler.JumpButtonUsed();
     SwordCharacter.JumpState.ResetAmountOfJumpsLeft();
     SwordCharacter.SetVelocityAngular(SwordCharacterData.WallJumpVelocity, SwordCharacterData.WallJumpAngle, _wallJumpDirection);
     SwordCharacter.CheckIfShouldFlip(_wallJumpDirection);
     SwordCharacter.JumpState.DecreaseAmountOfJumpsLeft();
 }
    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));
        }
    }
示例#4
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);
        }
    }
示例#5
0
    public override void LogicUpdate()
    {
        base.LogicUpdate();
        if (isExitingState)
        {
            return;
        }

        SwordCharacter.Anim.SetFloat("yVelocity", SwordCharacter.CurrentVelocity.y);
        SwordCharacter.Anim.SetFloat("xVelocity", Mathf.Abs(SwordCharacter.CurrentVelocity.x));

        if (_isHolding)
        {
            _airDashDirectionInput = SwordCharacter.InputHandler.DashDirectionInput;
            _dashInputStop         = SwordCharacter.InputHandler.DashInputStop;

            if (_airDashDirectionInput != Vector2.zero)
            {
                _airDashFaceDirection = _airDashDirectionInput;
                _airDashFaceDirection.Normalize();
            }

            if (_dashInputStop || Time.unscaledTime >= startTime + SwordCharacterData.AirDashMaxHoldTime)
            {
                _isHolding = false;
                SwordCharacter.SetShockWave(false);
                Time.timeScale = 1;
                startTime      = Time.time;
                SwordCharacter.CheckIfShouldFlip(Mathf.RoundToInt(_airDashFaceDirection.x));
                SwordCharacter.RB.drag = SwordCharacterData.Drag;
                SwordCharacter.SetVelocityEightDirectional(SwordCharacterData.AirDashVelocity, _airDashFaceDirection);
                PlaceAfterImage();
            }
        }
        else
        {
            SwordCharacter.SetVelocityEightDirectional(SwordCharacterData.AirDashVelocity, _airDashFaceDirection);
            CheckIfShouldPlaceAfterImage();
            if (Time.time >= startTime + SwordCharacterData.AirDashTimeDistance)
            {
                SwordCharacter.RB.drag = 0;
                IsAbilityDone          = true;
                _lastAirDashTime       = Time.time;
            }
        }
    }