Пример #1
0
    void Update()
    {
        // For the start: enabling day light and disabling night light for the crane bird
        if (lightManager.startingInDayLight == true)
        {
            lightManager.EnableNightLights();
            lightManager.startingInDayLight = false;
        }

        // Pressing LB or RB switches the lens on the list and triggers the LensSwitcher function
        if (gamepad.GetButtonDown("LB"))
        {
            if (lensCounter <= 0)
            {
                lensCounter = lensesList.Count - 1;
            }
            else
            {
                lensCounter = lensCounter - 1;
            }

            currentLens = lensesList[lensCounter];

            LensSwitcher(currentLens);
        }

        else if (gamepad.GetButtonDown("RB"))
        {
            if (lensCounter >= lensesList.Count - 1)
            {
                lensCounter = 0;
            }
            else
            {
                lensCounter = lensCounter + 1;
            }

            currentLens = lensesList[lensCounter];

            LensSwitcher(currentLens);
        }

        // Special transition made when coming back to normal
        if (noLensTransition == true)
        {
            noLensTransitionTimer += Time.deltaTime;
            if (noLensTransitionTimer >= 0.2)
            {
                bawShader.enabled   = false;
                postProcess.profile = noLenseProfile;

                cineCamera.m_Lens.FarClipPlane = noLenseDepthOfView;
                Camera.main.GetComponent <Skybox>().material   = daySkybox;
                Camera.main.GetComponent <Camera>().clearFlags = CameraClearFlags.Skybox;

                noLensTransition      = false;
                noLensTransitionTimer = 0;

                // Enables Day Light and disables Night Light in case the player is a crane and comes back from the night lense
                if (isCrane == true)
                {
                    lightManager.DisableNightLights();
                }
            }
        }

        // White transition for the night, maybe I can find a better idea...
        if (nightTransition == true)
        {
            nightTransitionTimer += Time.deltaTime;
            if (nightTransitionTimer >= 0.2)
            {
                bawShader.enabled              = false;
                postProcess.profile            = nightProfile;
                cineCamera.m_Lens.FarClipPlane = noLenseDepthOfView;

                Camera.main.GetComponent <Skybox>().material   = nightSkybox;
                Camera.main.GetComponent <Camera>().clearFlags = CameraClearFlags.Skybox;

                lightManager.EnableNightLights();

                nightTransition      = false;
                nightTransitionTimer = 0;

                lightManager.EnableNightLights();
            }
        }
    }