Exemplo n.º 1
0
    IEnumerator Fade(FadeType inOrOut)
    {
        float start, end;

        switch (inOrOut)
        {
        //****************************DO WHEN STARTING FADING IN:
        case FadeType.IN:
            start = 1;
            end   = 0;
            SetupNewEndDoor();
            ResetPlayerPosition();

            if (resetType == ResetType.ADVANCING)
            {
                _recorder.SpawnRecording();
            }

            _recorder.ReInit();
            _mover.AllowMovement(true);
            break;

        //**************************DO WHEN STARTING FADING OUT:
        case FadeType.OUT:
        default:
            start = 0;
            end   = 1;
            _mover.AllowMovement(false);
            _recorder.StopRecording();
            _detector.StopDetection();
            break;
        }


        var transStep = 0.0f;

        while (transStep <= 1)
        {
            transStep += Time.deltaTime / fadeTime;
            SetViewOpacity(Mathf.Lerp(start, end, transStep));
            //vignetteSettings.opacity = Mathf.Lerp(start, end, transStep);

            //Debug.LogWarning("Transstep is " + transStep);
            //ppProfile.vignette.settings = vignetteSettings;
            yield return(0);
        }

        switch (inOrOut)
        {
        case FadeType.IN:
            _recorder.StartRecording();
            _detector.StartDetection();
            break;

        case FadeType.OUT:
        default:
            StartCoroutine(Fade(FadeType.IN));
            break;
        }
    }