using System.Collections; using System.Collections.Generic; using UnityEngine; namespace ShotSimulator.Screen { public class ScreenEffectManager : MonoSingleton { private ScreenEffect[] m_ScreenEffects; private float brightness; private float saturation; private float contrast; private Color[] targetColors = new Color[] { new Color(20f/255f,191f/255f,237f/255f), new Color(20f/255f,237f/255f,149f/255f), new Color(237f/255f,237f/255f,20f/255f), new Color(239f/255f,17f/255f,17f/255f), }; private int targetColorIndex; public override void InitManager() { base.InitManager(); m_ScreenEffects = FindObjectsOfType(); SetBrightness(PlayerPrefs.HasKey("Brightness") ? PlayerPrefs.GetFloat("Brightness") : 1); SetSaturation(PlayerPrefs.HasKey("Saturation") ? PlayerPrefs.GetFloat("Saturation") : 1); SetTargetColorIndex(PlayerPrefs.HasKey("TargetColorIndex") ? PlayerPrefs.GetInt("TargetColorIndex") : 0); } public float GetBrightness() { return brightness; } public void SetBrightness(float value) { brightness = Mathf.Clamp(value, 0f, 4f); foreach(var effect in m_ScreenEffects) { effect.brightness = brightness; } PlayerPrefs.SetFloat("Brightness", brightness); } public float GetSaturation() { return saturation; } public void SetSaturation(float value) { saturation = Mathf.Clamp(value, 0f, 4f); foreach (var effect in m_ScreenEffects) { effect.saturation = saturation; } PlayerPrefs.SetFloat("Saturation", brightness); } public int GetTargetColorIndex() { return targetColorIndex; } public void SetTargetColorIndex(int index) { targetColorIndex = index; PlayerPrefs.SetInt("TargetColorIndex", index); } public Color GetTargetColor() { return targetColors[targetColorIndex]; } private Color TryParseHtmlColor(string colorString) { Color outColor; ColorUtility.TryParseHtmlString(colorString, out outColor); return outColor; } private void SetContrast(float value) { contrast = Mathf.Clamp(value, 0f, 4f); foreach (var effect in m_ScreenEffects) { effect.contrast = contrast; } } } }