Ejemplo n.º 1
0
    void Update()
    {
        if (state == states.INACTIVE)
        {
            return;
        }

        if (Game.Instance.state == Game.states.ENDED)
        {
            realSpeed -= 0.001f;
            if (realSpeed <= 0)
            {
                state = states.ENDED;
            }
        }
        else
        {
            realSpeed += 0.001f;
        }

        if (realSpeed > speed)
        {
            realSpeed = speed;
        }
        else if (realSpeed < 0)
        {
            realSpeed = 0;
        }

        float _speed = (realSpeed * 100) * Time.smoothDeltaTime;

        distance += _speed;

        if (state != states.ENDED)
        {
            foreach (BackgroundScrolleable bgScrolleable in backgroundsScrolleable)
            {
                bgScrolleable.UpdatePosition(distance, _speed);
            }

            camera.UpdatePosition(distance);
            characterManager.UpdatePosition(distance);

            if (state == states.ENDING)
            {
                return;
            }

            levelsManager.CheckForNewLevel(distance);
        }
    }