123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- 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<UIPopupList>();
- if (componentInChildren)
- {
- ScoutOption.NeedData needData = new ScoutOption.NeedData();
- if (transform.Find("Label"))
- {
- needData.label = transform.Find("Label").GetComponent<UILabel>();
- needData.localize = needData.label.GetComponent<Localize>();
- }
- needData.button = transform.GetComponentInChildren<UIButton>();
- needData.collider = transform.GetComponentInChildren<BoxCollider>();
- 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<UIPopupList, ScoutOption.NeedData> 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<UIPopupList>();
- 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<ScoutOption.UIInspectorSetting> settingList;
- public Action<ScoutOption.SettingType, string> onChangeValue;
- private Dictionary<UIPopupList, ScoutOption.NeedData> settingUIList = new Dictionary<UIPopupList, ScoutOption.NeedData>();
- 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;
- }
- }
- }
|