using System; using System.Collections.Generic; using UnityEngine; using wf; public class WindowPartsEffectGlobalFog : WindowPartsEffectBase { public override void Awake() { base.Awake(); this.fog_ = GameMain.Instance.MainCamera.GetComponent(); if (this.fog_ == null) { this.fog_ = GameMain.Instance.MainCamera.gameObject.AddComponent(); if (this.fog_.fogShader == null) { this.fog_.fogShader = Shader.Find("Hidden/GlobalFog"); } this.fog_.enabled = false; } this.fog_.startDistance = 5f; this.fog_.globalDensity = 1f; this.fog_.heightScale = 1f; this.fog_.globalFogColor = Color.white; this.backup_value_data_.startDistance = this.fog_.startDistance; this.backup_value_data_.globalDensity = this.fog_.globalDensity; this.backup_value_data_.heightScale = this.fog_.heightScale; this.backup_value_data_.height = this.fog_.height; this.backup_value_data_.globalFogColor = this.fog_.globalFogColor; string[] array = new string[] { "startDistance", "globalDensity", "heightScale", "height", "r", "g", "b" }; for (int i = 0; i < array.Length; i++) { PhotoSliderAndInput sliderAndInput = this.SettingInput.GetSliderAndInput(array[i]); if (sliderAndInput != null) { this.slider_dic_.Add(array[i], sliderAndInput); } } this.SettingInput.onChangeValue.Add(new Action(this.OnChangetValue)); this.ColorPaletteInput.onChangeValue.Add(new Action(this.OnChangetValue2)); this.OnChangeEffectEnabled(false); } public override void OnDestroy() { if (GameMain.Instance == null || GameMain.Instance.MainCamera == null || this.effect_object == null) { return; } UnityEngine.Object.Destroy(this.fog_); this.fog_ = null; } public override void OnChangeEffectEnabled(bool enabled) { WindowPartsInputSliderSet settingInput = this.SettingInput; this.ColorPaletteInput.enabled = enabled; settingInput.enabled = enabled; } public override void Init() { this.value_data_ = this.backup_value_data_; this.slider_dic_["startDistance"].ResetNum = this.backup_value_data_.startDistance; this.slider_dic_["globalDensity"].ResetNum = this.backup_value_data_.globalDensity; this.slider_dic_["heightScale"].ResetNum = this.backup_value_data_.heightScale; this.slider_dic_["height"].ResetNum = this.backup_value_data_.height; this.ColorPaletteInput.ResetNum = this.backup_value_data_.globalFogColor; this.EnabledCheckBox.check = false; this.UpdateGui(); } public void OnChangetValue(WindowPartsInputSliderSet.SliderAndInputSet input_object, float val) { if (input_object.Name == "startDistance") { this.value_data_.startDistance = val; } else if (input_object.Name == "globalDensity") { this.value_data_.globalDensity = val; } else if (input_object.Name == "heightScale") { this.value_data_.heightScale = val; } else if (input_object.Name == "height") { this.value_data_.height = val; } this.ApplyValue(); } public void OnChangetValue2(WindowPartsInputColorrPalette palette, Color color) { this.value_data_.globalFogColor = color; this.ApplyValue(); } public override void OnSerializeEvent() { Dictionary> woldStoreData = this.effect_window_.GetWoldStoreData(); woldStoreData["GlobalFog"] = new Dictionary(); Dictionary dictionary = woldStoreData["GlobalFog"]; this.value_data_.OnSerializeEvent(dictionary); dictionary.Add("enabled", base.effect_enabled.ToString()); } public override void OnDeserializeEvent() { Dictionary> woldStoreData = this.effect_window_.GetWoldStoreData(); if (!woldStoreData.ContainsKey("GlobalFog")) { this.ResetValue(); this.value_data_ = this.backup_value_data_; this.EnabledCheckBox.check = base.effect_enabled; } else { Dictionary dictionary = woldStoreData["GlobalFog"]; this.value_data_.OnDeserializeEvent(dictionary); base.effect_enabled = bool.Parse(dictionary["enabled"]); this.ApplyValue(); } this.UpdateGui(); } private void ApplyValue() { this.fog_.startDistance = this.value_data_.startDistance; this.fog_.globalDensity = this.value_data_.globalDensity; this.fog_.heightScale = this.value_data_.heightScale; this.fog_.height = this.value_data_.height; this.fog_.globalFogColor = this.value_data_.globalFogColor; } public void ResetValue() { this.fog_.startDistance = this.backup_value_data_.startDistance; this.fog_.globalDensity = this.backup_value_data_.globalDensity; this.fog_.heightScale = this.backup_value_data_.heightScale; this.fog_.height = this.backup_value_data_.height; this.fog_.globalFogColor = this.backup_value_data_.globalFogColor; base.effect_enabled = false; } public void UpdateGui() { this.slider_dic_["startDistance"].value = this.value_data_.startDistance; this.slider_dic_["globalDensity"].value = this.value_data_.globalDensity; this.slider_dic_["heightScale"].value = this.value_data_.heightScale; this.slider_dic_["height"].value = this.value_data_.height; this.ColorPaletteInput.value = this.value_data_.globalFogColor; this.EnabledCheckBox.check = base.effect_enabled; this.OnChangeEffectEnabled(this.EnabledCheckBox.check); } protected override MonoBehaviour effect_object { get { return this.fog_; } } private const string kStoreName = "GlobalFog"; public WindowPartsInputSliderSet SettingInput; public WindowPartsInputColorrPalette ColorPaletteInput; private Dictionary slider_dic_ = new Dictionary(); private GlobalFog fog_; private WindowPartsEffectGlobalFog.Data backup_value_data_; private WindowPartsEffectGlobalFog.Data value_data_; private struct Data { public void OnSerializeEvent(Dictionary effect_store_data) { effect_store_data.Add("startDistance", this.startDistance.ToString("G9")); effect_store_data.Add("globalDensity", this.globalDensity.ToString("G9")); effect_store_data.Add("heightScale", this.heightScale.ToString("G9")); effect_store_data.Add("height", this.height.ToString("G9")); effect_store_data.Add("globalFogColor", this.globalFogColor.ToString("G9")); } public void OnDeserializeEvent(Dictionary effect_restore_data) { this.startDistance = float.Parse(effect_restore_data["startDistance"]); this.globalDensity = float.Parse(effect_restore_data["globalDensity"]); this.heightScale = float.Parse(effect_restore_data["heightScale"]); this.height = float.Parse(effect_restore_data["height"]); this.globalFogColor = Parse.Color(effect_restore_data["globalFogColor"]); } public float startDistance; public float globalDensity; public float heightScale; public float height; public Color globalFogColor; } }