using System; using System.Collections; using System.Collections.Generic; using System.Linq; using I2.Loc; using UnityEngine; namespace scoutmode { public class ScoutOption : MonoBehaviour { private ScoutOptionData options { get { return ScoutManager.Instance.options; } } private void Start() { IEnumerator enumerator = this.buttonGroup.GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; Transform transform = (Transform)obj; UIPopupList componentInChildren = transform.GetComponentInChildren(); if (componentInChildren) { ScoutOption.NeedData needData = new ScoutOption.NeedData(); if (transform.Find("Label")) { needData.label = transform.Find("Label").GetComponent(); needData.localize = needData.label.GetComponent(); } needData.button = transform.GetComponentInChildren(); needData.collider = transform.GetComponentInChildren(); this.settingUIList.Add(componentInChildren, needData); EventDelegate.Add(componentInChildren.onChange, new EventDelegate.Callback(this.OnValueSetting)); } } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } this.UpdateUI(); } public void DisSelectable() { foreach (KeyValuePair keyValuePair in this.settingUIList) { if (keyValuePair.Value.collider) { keyValuePair.Value.collider.enabled = false; } } } public void UpdateUI() { IEnumerator enumerator = this.buttonGroup.GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; Transform transform = (Transform)obj; UIPopupList componentInChildren = transform.GetComponentInChildren(); if (componentInChildren != null) { this.SetUIValue(componentInChildren); } } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } } private void SetUIValue(UIPopupList list) { ScoutOption.UIInspectorSetting uiinspectorSetting = this.settingList.SingleOrDefault((ScoutOption.UIInspectorSetting e) => e.popUpUI == list); if (uiinspectorSetting == null) { return; } foreach (string text in list.items) { bool flag = false; string text2 = text.Replace("\r", string.Empty); string text3 = text2; string[] array = text2.Split(new char[] { '/' }); if (array != null && 1 < array.Length) { text3 = array[array.Length - 1]; flag = true; } if (this.IsMatch(uiinspectorSetting.myType, text3)) { list.value = ((!flag) ? text3 : text2); break; } } } private bool IsMatch(ScoutOption.SettingType type, string text) { bool result = false; if (type == ScoutOption.SettingType.BaseChara) { if (this.options.baseCharaSelect) { result = (text == "登録キャラから選択する"); } else { result = (text == "登録キャラからランダム"); } } else if (type == ScoutOption.SettingType.Personality || type == ScoutOption.SettingType.Seikeiken || type == ScoutOption.SettingType.MaidPoint) { bool flag = false; if (type != ScoutOption.SettingType.Personality) { if (type != ScoutOption.SettingType.Seikeiken) { if (type == ScoutOption.SettingType.MaidPoint) { flag = this.options.inheritMaidPoint; } } else { flag = this.options.inheritSeikeiken; } } else { flag = this.options.inheritPersonality; } if (flag) { result = (text == "①のキャラと同じ"); } else { result = (text == "ランダム"); } } else if (type == ScoutOption.SettingType.BaseCharaDelete) { if (this.options.isBaseCharaDelete) { result = (text == "①のベースキャラを消す"); } else { result = (text == "①のベースキャラを消さない"); } } return result; } private void OnValueSetting() { string text = UIPopupList.current.value.Replace("\r", string.Empty); string text2 = text; bool isLocalized = UIPopupList.current.isLocalized; if (isLocalized) { string[] array = text2.Split(new char[] { '/' }); if (array != null && 1 < array.Length) { text2 = array[array.Length - 1]; } } ScoutOption.UIInspectorSetting uiinspectorSetting = this.settingList.SingleOrDefault((ScoutOption.UIInspectorSetting e) => e.popUpUI == UIPopupList.current); if (uiinspectorSetting == null) { return; } if (uiinspectorSetting.myType == ScoutOption.SettingType.BaseChara) { this.options.baseCharaSelect = (text2 == "登録キャラから選択する"); } else if (uiinspectorSetting.myType == ScoutOption.SettingType.Personality) { this.options.inheritPersonality = (text2 == "①のキャラと同じ"); } else if (uiinspectorSetting.myType == ScoutOption.SettingType.Seikeiken) { this.options.inheritSeikeiken = (text2 == "①のキャラと同じ"); } else if (uiinspectorSetting.myType == ScoutOption.SettingType.MaidPoint) { this.options.inheritMaidPoint = (text2 == "①のキャラと同じ"); } else if (uiinspectorSetting.myType == ScoutOption.SettingType.BaseCharaDelete) { this.options.isBaseCharaDelete = (text2 == "①のベースキャラを消す"); } if (this.settingUIList[UIPopupList.current].label) { if (isLocalized && this.settingUIList[UIPopupList.current].localize != null) { this.settingUIList[UIPopupList.current].localize.SetTerm(text); } else { this.settingUIList[UIPopupList.current].label.text = text; } } if (this.onChangeValue != null) { this.onChangeValue(uiinspectorSetting.myType, text2); } } [SerializeField] [Header("ボタンUIグループ")] private Transform buttonGroup; [SerializeField] [Header("各UI設定")] private List settingList; public Action onChangeValue; private Dictionary settingUIList = new Dictionary(); public enum SettingType { BaseChara, Personality, Seikeiken, MaidPoint, BaseCharaDelete } private class NeedData { public UILabel label; public Localize localize; public UIButton button; public BoxCollider collider; } [Serializable] private class UIInspectorSetting { public ScoutOption.SettingType myType; public UIPopupList popUpUI; } } }