Beispiel #1
0
    private void Update()
    {
        if (WalkRightEndlessly)
        {
            deltaMovement = new Vector2(movementParameters.maxMovementSpeed * Time.deltaTime, 0.0f);
        }
        else if (!MovementEnabled)
        {
            deltaMovement = Vector2.zero;
        }
        else
        {
            movementSystem.Calculate();

            Vector2 mTotalVelocity = new Vector2(
                movementSystem.AccumulatedVelocity,
                0.0f);

            deltaMovement = mTotalVelocity * Time.deltaTime;

            stairsSystem.Calculate(ref deltaMovement);
            if (collisionSystem.enabled)
            {
                deltaMovement = collisionSystem.Calculate(deltaMovement);
            }

            movementSystem.UpdateCollisionData();
        }

        if (deltaMovement.x != 0.0f)
        {
            MovementDirection = deltaMovement.x > 0.0f ? 1 : 0;
            int direction = (int)Mathf.Sign(deltaMovement.x);

            if (previousDirection != direction)
            {
                Rotate(direction);
            }
        }

        mAnimator.SetBool("walk", deltaMovement.x != 0.0f);
    }