示例#1
0
    void Update()
    {
        if (onGround)
        {
            PlayerUtility.PlayerAction(body2D, RUNNING_VELOCITY, NO_VELOCITY);
            PlayerUtility.ChangeAnimation(animator, RUNNING_ANIMATION);
        }

        if (PlayerUtility.CanJump(onGround, Input.GetKey(SPACE)))
        {
            PlayerUtility.PlayerAction(body2D, RUNNING_VELOCITY, JUMPING_VELOCITY);
            body2D.AddForce((Vector2.right * RUNNING_VELOCITY) * THRUST);
        }

        if (player.transform.position.x >= FINISH_LOCATION_X_AXIS)
        {
            PlayerUtility.PlayerAction(body2D, NO_VELOCITY, NO_VELOCITY);
            PlayerUtility.ChangeAnimation(animator, IDLE_ANIMATION);
            txt.text = LEVEL_COMPLETE_MESSAGE;
            AttemptsTracker.setAttemptLevelThreeToZero();
        }
    }