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;
        }
    }
Example #2
0
 public override void Exit()
 {
     base.Exit();
     if (SwordCharacter.CurrentVelocity.y > 0)
     {
         SwordCharacter.SetVelocityY(SwordCharacter.CurrentVelocity.y * SwordCharacterData.DashEndYMultiplier);
     }
 }
Example #3
0
 public override void DoChecks()
 {
     base.DoChecks();
     _isGrounded             = SwordCharacter.CheckIfTouchingGround();
     _isGrabbable            = SwordCharacter.CheckIfIsGrabbable();
     _isTouchingWallAbove    = SwordCharacter.CheckIfTouchingWallAbove();
     _isTouchingGrabbleAbove = SwordCharacter.CheckIfTouchingGrabbableAbove();
 }
 public override void Enter()
 {
     base.Enter();
     SwordCharacter.InputHandler.JumpButtonUsed();
     SwordCharacter.SetVelocityY(SwordCharacterData.JumpVelocity);
     IsAbilityDone = true;
     _amountsOfJumpsLeft--;
     SwordCharacter.AirState.SetIsJumping();
 }
Example #5
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();
 }
Example #6
0
    public override void Enter()
    {
        base.Enter();
        SwordCharacter.SetVelocityZero();
        SwordCharacter.transform.position = _detectedPos;
        _cornerPos = SwordCharacter.DetermineCornerPosition();

        _startPos.Set(_cornerPos.x - (SwordCharacter.FacingDirection * SwordCharacterData.StartOffset.x), _cornerPos.y - SwordCharacterData.StartOffset.y);
        _stopPos.Set(_cornerPos.x + (SwordCharacter.FacingDirection * SwordCharacterData.StopOffset.x), _cornerPos.y + SwordCharacterData.StartOffset.y);
        SwordCharacter.transform.position = _startPos;
    }
Example #7
0
 public override void Enter()
 {
     base.Enter();
     SwordCharacter.SetShockWave(true);
     CanAirDash = false;                                                     //As we enter we used our dash
     SwordCharacter.InputHandler.DashInputUsed();                            //Let the input known
     _isHolding            = true;
     _airDashFaceDirection = Vector2.right * SwordCharacter.FacingDirection; //dash direction
     Time.timeScale        = SwordCharacterData.HoldTimeScale;               //Bullet Time
     startTime             = Time.unscaledTime;                              //Since time is slowed down, startTime should be override
 }
    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));
        }
    }
Example #9
0
    public override void LogicUpdate()
    {
        base.LogicUpdate();
        if (isExitingState)
        {
            return;
        }

        SwordCharacter.SetVelocityY(-SwordCharacterData.WallSlideVelocity);
        if (GrabInput && IsTouchingGrabbable)
        {
            SwordCharaterStateMachine.ChangeState(SwordCharacter.WallGrabState);
        }
    }
Example #10
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);
        }
    }
 private void CheckJumpMultiplier()
 {
     if (_isJumping)
     {
         if (_jumpInputStop)
         {
             SwordCharacter.SetVelocityY(SwordCharacter.CurrentVelocity.y * SwordCharacterData.JumpHeightMultiplier);
             _isJumping = false;
         }
         else if (SwordCharacter.CurrentVelocity.y <= 0f)
         {
             _isJumping = false;
         }
     }
 }
Example #12
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);
        }
    }
Example #13
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;
            }
        }
    }
Example #14
0
    public override void LogicUpdate()
    {
        base.LogicUpdate();
        if (isAnimationFinished)
        {
            SwordCharaterStateMachine.ChangeState(SwordCharacter.IdleState);
        }
        else
        {
            _xInput    = SwordCharacter.InputHandler.InputX;
            _yInput    = SwordCharacter.InputHandler.InputY;
            _jumpInput = SwordCharacter.InputHandler.JumpInput;
            SwordCharacter.SetVelocityZero();

            if (!_isClimbing)
            {
                SwordCharacter.transform.position = _startPos;
            }
            else
            {
                SwordCharacter.transform.position = Vector3.MoveTowards(SwordCharacter.transform.position, _stopPos, SwordCharacterData.OffsetTransition * Time.deltaTime);
            }

            if (_xInput == SwordCharacter.FacingDirection && _isHanging && !_isClimbing && Time.time > _timer + _inputDelay)
            {
                _isClimbing = true;
                SwordCharacter.Anim.SetBool("ledgeClimbUp", true);
            }
            else if (_yInput == -1 && _isHanging && !_isClimbing)
            {
                SwordCharaterStateMachine.ChangeState(SwordCharacter.AirState);
            }
            //else if(_jumpInput && !_isClimbing && Time.time > _timer + _inputDelay)
            //{
            //    SwordCharacter.WallJumpState.CheckWallJumpDirection(true);
            //    SwordCharaterStateMachine.ChangeState(SwordCharacter.WallJumpState);
            //}
        }
    }
    public override void LogicUpdate()
    {
        base.LogicUpdate();
        if (isExitingState)
        {
            return;
        }

        if (YInput > 0 && IsTouchingGrabbable && GrabInput)
        {
            SwordCharacter.SetVelocityY(SwordCharacterData.WallClimbVelocity);
        }
        if (YInput < 0 && IsTouchingGrabbable && GrabInput)
        {
            SwordCharacter.SetVelocityY(-SwordCharacterData.WallClimbVelocity);
        }

        if (YInput == 0 && IsTouchingGrabbable && GrabInput || IsTouchingWallAbove && YInput > 0)
        {
            SwordCharaterStateMachine.ChangeState(SwordCharacter.WallGrabState);
        }
        //If player hold down while grabbing, it should stands idle
        else if (YInput < 0 && IsTouchingGrabbable && GrabInput && IsGrounded)
        {
            SwordCharaterStateMachine.ChangeState(SwordCharacter.IdleState);
        }
        //Smooth transition between climb and slide
        else if ((IsTouchingGrabbable || IsTouchingWall) && !GrabInput && XInput == SwordCharacter.FacingDirection)
        {
            SwordCharaterStateMachine.ChangeState(SwordCharacter.WallSlideState);
        }
        //If none of it is true just release from wall
        else if (!IsTouchingGrabbable)
        {
            SwordCharaterStateMachine.ChangeState(SwordCharacter.AirState);
        }
    }
 public override void Enter()
 {
     base.Enter();
     SwordCharacter.SetVelocityX(0f);
 }
 private void HoldPosition()
 {
     SwordCharacter.transform.position = _holdPosition;
     SwordCharacter.SetVelocityZero();
 }
 public override void DoChecks()
 {
     base.DoChecks();
     IsGrounded     = SwordCharacter.CheckIfTouchingGround();
     IsTouchingWall = SwordCharacter.CheckIfTouchingWall();
 }