// Start is called before the first frame update void Start() { mPostProcessing = GetComponent <Volume>(); mPostProcessing.profile.TryGet(out mVignette); mPostProcessing.profile.TryGet(out mColorAdjustments); mDefaultProcessingState = new PostProcessingStates { mVignetteColor = mVignette.color.value, mVignetteIntensity = mVignette.intensity.value, mVignetteSmoothness = mVignette.smoothness.value, mColorContrast = mColorAdjustments.contrast.value, mColorSaturation = mColorAdjustments.saturation.value }; mCurrentProcessingState = mDefaultProcessingState; GameObject player = GameObject.Find("Player"); if (player != null) { mHealthController = player.GetComponent <HealthController>(); mHealthController.OnDamaged += IncreaseHurtIntensity; } mHurtEffectStart = 3.40282347E+38F; }
private void SetProcessingState(PostProcessingStates s) { mVignette.color.Override(s.mVignetteColor); mVignette.intensity.Override(s.mVignetteIntensity); mVignette.smoothness.Override(s.mVignetteSmoothness); mColorAdjustments.contrast.Override(s.mColorContrast); mColorAdjustments.saturation.Override(s.mColorSaturation); }
public void IncreaseHurtIntensity() { mHurtEffectStart = Time.time; mCurrentProcessingState = DamagedIntensity[mHurtLevel]; if (mHurtLevel < DamagedIntensity.Length - 1) { mHurtLevel++; } SetProcessingState(mCurrentProcessingState); }
private PostProcessingStates LerpProcessingState(PostProcessingStates a, PostProcessingStates b, float progress) { ColorParameter vColor = new ColorParameter(a.mVignetteColor); vColor.Interp(a.mVignetteColor, b.mVignetteColor, progress); PostProcessingStates toReturn = new PostProcessingStates { mColorContrast = Mathf.Lerp(a.mColorContrast, b.mColorContrast, progress), mColorSaturation = Mathf.Lerp(a.mColorSaturation, b.mColorSaturation, progress), mVignetteColor = vColor.value, mVignetteIntensity = Mathf.Lerp(a.mVignetteIntensity, b.mVignetteIntensity, progress), mVignetteSmoothness = Mathf.Lerp(a.mVignetteSmoothness, b.mVignetteSmoothness, progress) }; return(toReturn); }
// Update is called once per frame void Update() { float currentTime = Time.time; if (currentTime > mHurtEffectStart + HurtDuration && currentTime <= mHurtEffectStart + HurtDuration + HurtFadeAwayTime) { float progress = (currentTime - mHurtEffectStart - HurtDuration) / HurtFadeAwayTime; SetProcessingState(LerpProcessingState(mCurrentProcessingState, mDefaultProcessingState, progress)); } if (currentTime > mHurtEffectStart + HurtDuration + HurtFadeAwayTime) { mHurtLevel = 0; mHurtEffectStart = 3.40282347E+38F; mCurrentProcessingState = mDefaultProcessingState; } }