Пример #1
0
        private void UpdateEffects()
        {
#if UNITY_EDITOR
            SetBaseColors(Globals.singleton.baseCameraEffect.effect.colors);
#endif

            if (_baseEffect == null)
            {
                return;
            }

            // Define base colors
            CameraEffect.Effect.Colors baseColors = new CameraEffect.Effect.Colors(_baseEffect);

            float intensity = 0;
            float shake     = 0;

            for (int i = 0; i < _effects.Count; i++)
            {
                CameraEffect.Effect effectSettings = _effects[i];

                // Define scale
                float duration      = effectSettings.properties.killTime - effectSettings.properties.startTime;
                float timeRemaining = effectSettings.properties.killTime - Time.time;

                float scale = duration == 0 ? 0 : timeRemaining / duration;

                float shakeScale = effectSettings.shake.intensityOverLifetime.Evaluate(1 - scale);
                intensity += effectSettings.shake.intensityMultiplier * shakeScale;
                float direction = 1;
                direction = direction.RandomDirection();
                shake    += direction * intensity;

                float colorScale = effectSettings.colors.intensityOverLifetime.Evaluate(1 - scale) * effectSettings.colors.colorIntensity;
                // Combine effects into base colors
                CombineColors(effectSettings.colors, ref baseColors, colorScale);

                // Remove camera effect if it has become durated
                if (Time.time >= effectSettings.properties.killTime)
                {
                    i--;
                    _effects.Remove(effectSettings);
                }
            }
            ApplyColorEffects(baseColors);
            this.transform.eulerAngles += new Vector3(0, 0, shake);
            _camera.fieldOfView         = _camera.fieldOfView + shake;
        }
Пример #2
0
        internal void AddEffect(CameraEffect.Effect effectSettings)
        {
            // Try to find an existing effect, and update its times
            for (int i = 0; i < _effects.Count; i++)
            {
                if (_effects[i].uniqueId == effectSettings.uniqueId)
                {
                    _effects[i] = effectSettings;
                    return;
                }
            }

            // Create new instance of effect settings
            CameraEffect.Effect newEffectSettings = new CameraEffect.Effect(effectSettings);
            _effects.Add(newEffectSettings);
        }