Пример #1
0
    private void SetShaderValueInternal(ShaderValue value)
    {
        ShaderDefaultValue defaultValue;

        if (_processingValues.Any(bundle => bundle.Value.ShaderType == value.ShaderType))
        {
            defaultValue = _processingValues.First(bundle => bundle.Value.ShaderType == value.ShaderType).DefaultValue;
        }
        else
        {
            float defaultFloat = 0f;
            Color defaultColor = Color.black;

            if (value.ShaderType == ShaderType.ColorGrading_Filter)
            {
                defaultColor = _shaderColorGrading.colorFilter.value;
            }
            else if (value.ShaderType == ShaderType.DepthOfField_Distance)
            {
                defaultFloat = _shaderDepthOfField.focusDistance.value;
            }
            else if (value.ShaderType == ShaderType.ChromaticAberration_Intensity)
            {
                defaultFloat = _shaderChromaticAberration.intensity.value;
            }

            defaultValue = new ShaderDefaultValue {
                DefaultFloat = defaultFloat,
                DefaultColor = defaultColor
            };
        }

        _processingValues.Add(new ShaderValueBundle {
            StartTime    = Time.time,
            Value        = value,
            DefaultValue = defaultValue
        });
    }
Пример #2
0
    private void Update()
    {
        if (Intro)
        {
            if (_introStart.Equals(0f))
            {
                _introStart = Time.time;
            }

            float perc = (Time.time - _introStart) / 5f;
            if (perc <= .5f)
            {
                _imageY = perc / .5f;
                _bgA    = 1f;
                _imageA = 1f;
            }
            else
            {
                _imageY = 1f;
                _bgA    = 1f - (perc - .5f) / .5f;
                _imageA = _bgA;
            }

            if (perc >= 1f)
            {
                Intro       = false;
                _introStart = 0f;
            }
        }

        float desiredHealthOnion = GameManager.Instance.StatusHuntersHealth / (float)GameManager.Instance.StatusHuntersMaxHealth;

        if (_huntersHealthOnion > desiredHealthOnion)
        {
            _huntersHealthOnion = Mathf.MoveTowards(_huntersHealthOnion, desiredHealthOnion, Time.deltaTime * .5f);
        }
        else
        {
            _huntersHealthOnion = desiredHealthOnion;
        }

        desiredHealthOnion = GameManager.Instance.StatusVictimsHealth / (float)GameManager.Instance.StatusVictimsMaxHealth;
        if (_victimsHealthOnion > desiredHealthOnion)
        {
            _victimsHealthOnion = Mathf.MoveTowards(_victimsHealthOnion, desiredHealthOnion, Time.deltaTime * .5f);
        }
        else
        {
            _victimsHealthOnion = desiredHealthOnion;
        }

        for (var i = 0; i < _processingValues.Count; i++)
        {
            ShaderValueBundle  valueBundle  = _processingValues[i];
            ShaderValue        value        = valueBundle.Value;
            ShaderDefaultValue defaultValue = valueBundle.DefaultValue;

            if (Time.time >= valueBundle.StartTime && Time.time <= valueBundle.StartTime + value.TimeFull)
            {
                float time       = Time.time - valueBundle.StartTime;
                float transition = time <= value.TimeIn ? time / value.TimeIn : time >= value.TimeFull - value.TimeOut ? 1f - (time - (value.TimeFull - value.TimeOut)) / value.TimeOut : 1f;
                Debug.Log(transition);
                if (value.ShaderType == ShaderType.ColorGrading_Filter)
                {
                    _shaderColorGrading.colorFilter.value = ColorTransition(defaultValue.DefaultColor, value.ColorValue, transition);
                }
                else if (value.ShaderType == ShaderType.DepthOfField_Distance)
                {
                    _shaderDepthOfField.focusDistance.value = FloatTransition(defaultValue.DefaultFloat, value.FloatValue, transition);
                }
                else if (value.ShaderType == ShaderType.ChromaticAberration_Intensity)
                {
                    _shaderChromaticAberration.intensity.value = FloatTransition(defaultValue.DefaultFloat, value.FloatValue, transition);
                }
            }
            else
            {
                if (value.ShaderType == ShaderType.ColorGrading_Filter)
                {
                    _shaderColorGrading.colorFilter.value = defaultValue.DefaultColor;
                }
                else if (value.ShaderType == ShaderType.DepthOfField_Distance)
                {
                    _shaderDepthOfField.focusDistance.value = defaultValue.DefaultFloat;
                }
                else if (value.ShaderType == ShaderType.ChromaticAberration_Intensity)
                {
                    _shaderChromaticAberration.intensity.value = defaultValue.DefaultFloat;
                }

                _processingValues.RemoveAt(i);
                i--;
            }
        }
    }