示例#1
0
    void Update()
    {
        animationController.GetCurrentState();

        if (animationController.animationHashes.hs_Current != animationController.animationHashes.hs_Last &&
            (animationController.animationHashes.hs_Last == animationController.animationHashes.hs_Dash || animationController.animationHashes.hs_Last == animationController.animationHashes.hs_Air_Dash) &&
            AfterImageCorutine != null)
        {
            StopAfterImage();
        }

        ReadInput();
        if (!GameManager.instance.gamePaused)
        {
            InputToVelocity();
            SetSpriteDirecction();
            controller.Move(ref moveVec);

            if (animationController.animationHashes.hs_Current != animationController.animationHashes.hs_Air_Dash)
            {
                verticalVelocity += gravity * Time.deltaTime;
                if (controller.cs.collidingUp)
                {
                    verticalVelocity = gravity * Time.deltaTime;
                }
                verticalVelocity = Mathf.Max(verticalVelocity, maxFallingSpeed);
            }

            CalculateJumpForceAndGravity();
            CalculateDashForce();

            if (!playerStatus.pressedJumpButton)
            {
                GameManager.instance.PlayerMoved();
            }

            animationController.SetAnimationParameters();

            if (controller.cs.collidingDown)
            {
                playerStatus.extraJumps = 1;
                verticalVelocity        = 0;
                playerStatus.airDashes  = 1;
            }

            playerStatus.Reset();

            moveVecOld = moveVec;
        }

        HandleInputBuffer();
    }