123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413 |
- using System;
- using System.Collections.Generic;
- using I2.Loc;
- using MaidStatus;
- using MaidStatus.CsvData;
- using UnityEngine;
- using wf;
- using Yotogis;
- public class YotogiClassListManager : MonoBehaviour
- {
- public static List<YotogiClassListManager.Data> CreateDatas(Status status)
- {
- List<YotogiClass.Data> list = new List<YotogiClass.Data>();
- foreach (YotogiClass.Data data in YotogiClass.GetAllDatas(true))
- {
- if (data.learnConditions.isLearnPossiblePersonal(status.personal) && data.classType != AbstractClassData.ClassType.Old)
- {
- list.Add(data);
- }
- }
- return YotogiClassListManager.CreateDatas(list, status);
- }
- public static List<YotogiClassListManager.Data> CreateDatasOld(Status status)
- {
- List<YotogiClass.Data> list = new List<YotogiClass.Data>();
- foreach (YotogiClass.Data data in YotogiClass.GetAllDatas(true))
- {
- if (data.learnConditions.isLearnPossiblePersonal(status.personal) && data.classType != AbstractClassData.ClassType.New)
- {
- list.Add(data);
- }
- }
- return YotogiClassListManager.CreateDatas(list, status);
- }
- private static List<YotogiClassListManager.Data> CreateDatas(List<YotogiClass.Data> datas, Status status)
- {
- List<YotogiClassListManager.Data> list = new List<YotogiClassListManager.Data>();
- List<KeyValuePair<string[], bool>> list2 = new List<KeyValuePair<string[], bool>>();
- foreach (YotogiClass.Data data in datas)
- {
- list2 = data.learnConditions.CreateConditionTextAndStaturResults(status);
- YotogiClassListManager.Data data2 = new YotogiClassListManager.Data();
- data2.classData = data;
- data2.isLearn = status.yotogiClass.Contains(data2.classData);
- data2.conditionDatas = list2.ToArray();
- data2.specialSkillList = YotogiClass.GetLearnSkillList(data2.classData.id);
- data2.specialSkillOldList = YotogiClass.GetLearnSkillOldList(data2.classData.id);
- list.Add(data2);
- }
- list.Sort();
- return list;
- }
- private void Awake()
- {
- if (this.conditionDatas != null)
- {
- return;
- }
- this.itemGrid = this.contentObject.GetComponent<UIGrid>();
- NDebug.AssertNull(this.itemGrid != null);
- this.conditionList = this.conditionsObject.GetComponentInChildren<UIWFConditionList>();
- NDebug.AssertNull(this.conditionList != null);
- this.conditionBG = UTY.GetChildObject(this.conditionsObject, "BG", false).GetComponent<UIWidget>();
- for (int i = 0; i < 50; i++)
- {
- this.InstantiateItem(this.storageObject);
- }
- this.conditionDatas = new Dictionary<int, KeyValuePair<string[], Color>[]>();
- this.instansToDatas = new Dictionary<int, YotogiClassListManager.Data>();
- this.conditionsObject.SetActive(false);
- this.specialSkillLabelsParent.SetActive(false);
- this.specialSkillLabelList = new List<UILabel>(UTY.GetChildObject(this.specialSkillLabelsParent, "UnitParent", false).GetComponentsInChildren<UILabel>());
- ClassChangePanel.CreateClassText();
- }
- public void CreateData(Maid maid)
- {
- if (this.conditionDatas == null)
- {
- this.Awake();
- }
- this.DeleteItemAllObject();
- this.conditionDatas.Clear();
- this.instansToDatas.Clear();
- Utility.ResetNGUI(this.itemGrid);
- Utility.ResetNGUI(this.scrollView);
- bool lockNTRPlay = GameMain.Instance.CharacterMgr.status.lockNTRPlay;
- List<KeyValuePair<string, Color>> list = new List<KeyValuePair<string, Color>>();
- int num = 0;
- List<YotogiClassListManager.Data> list2;
- if (MaidManagement.compatibilityMode)
- {
- list2 = YotogiClassListManager.CreateDatasOld(maid.status);
- }
- else
- {
- list2 = YotogiClassListManager.CreateDatas(maid.status);
- }
- List<YotogiClassListManager.Data> list3 = new List<YotogiClassListManager.Data>();
- foreach (YotogiClassListManager.Data data in list2)
- {
- if (!lockNTRPlay || !YotogiClass.IsNTRClass(data.classData.id, MaidManagement.compatibilityMode))
- {
- if (data.classData.learnConditions.isSpecialConditions())
- {
- AbstractClassData.LearnConditions learnConditions = data.classData.learnConditions;
- if (data.isLearn && !learnConditions.CheckSpecialConditions(maid.status))
- {
- continue;
- }
- if (!data.isLearn && !learnConditions.isFutureLearnPossible(maid.status))
- {
- continue;
- }
- }
- if (data.classData != null && data.classData.learnConditions.requestPersonals.Count != 0 && data.classData.classType != AbstractClassData.ClassType.Old)
- {
- list3.Add(data);
- }
- else
- {
- GameObject gameObject = this.CreateItemObject(maid, ++num, data);
- if (0 < data.conditionDatas.Length)
- {
- List<KeyValuePair<string[], Color>> list4 = new List<KeyValuePair<string[], Color>>();
- foreach (KeyValuePair<string[], bool> keyValuePair in data.conditionDatas)
- {
- list4.Add(new KeyValuePair<string[], Color>(keyValuePair.Key, (!keyValuePair.Value) ? Color.gray : Color.white));
- }
- this.conditionDatas.Add(gameObject.GetInstanceID(), list4.ToArray());
- this.instansToDatas.Add(gameObject.GetInstanceID(), data);
- }
- }
- }
- }
- foreach (YotogiClassListManager.Data data2 in list3)
- {
- GameObject gameObject2 = this.CreateItemObject(maid, -1, data2);
- if (0 < data2.conditionDatas.Length)
- {
- List<KeyValuePair<string[], Color>> list5 = new List<KeyValuePair<string[], Color>>();
- if (data2.classData != null)
- {
- foreach (int num2 in data2.classData.learnConditions.requestPersonals)
- {
- if (maid.status.personal.id == num2)
- {
- string text = GameUty.supportMultiLanguage ? maid.status.personal.termName : maid.status.personal.drawName;
- list5.Add(new KeyValuePair<string[], Color>(new string[]
- {
- "MaidStatus/条件文/ヒロインタイプ {0}",
- text
- }, Color.white));
- break;
- }
- }
- }
- foreach (KeyValuePair<string[], bool> keyValuePair2 in data2.conditionDatas)
- {
- list5.Add(new KeyValuePair<string[], Color>(keyValuePair2.Key, (!keyValuePair2.Value) ? Color.gray : Color.white));
- }
- this.conditionDatas.Add(gameObject2.GetInstanceID(), list5.ToArray());
- this.instansToDatas.Add(gameObject2.GetInstanceID(), data2);
- }
- }
- Utility.ResetNGUI(this.itemGrid);
- Utility.ResetNGUI(this.scrollView);
- }
- private void OnEnable()
- {
- Utility.ResetNGUI(this.itemGrid);
- Utility.ResetNGUI(this.scrollView);
- this.OnHoverOutItem();
- }
- private GameObject InstantiateItem(GameObject parent)
- {
- GameObject gameObject = Utility.CreatePrefab(parent, "SceneEdit/Profile/Prefab/ProfileYotogiSkillItemSimple", true);
- UIEventTrigger component = gameObject.GetComponent<UIEventTrigger>();
- EventDelegate eventDelegate = new EventDelegate(this, "OnHoverOverItem");
- eventDelegate.parameters[0].value = gameObject.GetInstanceID();
- EventDelegate.Add(component.onHoverOver, eventDelegate);
- EventDelegate.Add(component.onHoverOut, new EventDelegate.Callback(this.OnHoverOutItem));
- return gameObject;
- }
- private void OnHoverOverItem(int instanceId)
- {
- if (this.conditionDatas.ContainsKey(instanceId))
- {
- YotogiClassListManager.Data data = this.instansToDatas[instanceId];
- this.conditionTitleLabel.text = data.classData.drawName + " 取得条件";
- if (GameUty.supportMultiLanguage)
- {
- Localize component = this.conditionTitleLabel.GetComponent<Localize>();
- if (component != null)
- {
- string termName = data.classData.termName;
- Localize.ArgsPair[] termArgs = new Localize.ArgsPair[]
- {
- Localize.ArgsPair.Create(" {0}", false),
- Localize.ArgsPair.Create("System/取得条件", true)
- };
- component.TermArgs = termArgs;
- component.SetTerm(termName);
- }
- }
- this.conditionList.SetTexts(this.conditionDatas[instanceId], 500);
- this.conditionBG.height = 90 + this.conditionList.height;
- this.conditionsObject.SetActive(true);
- foreach (UILabel uilabel in this.specialSkillLabelList)
- {
- uilabel.text = string.Empty;
- }
- int num = 0;
- if (MaidManagement.compatibilityMode)
- {
- foreach (KeyValuePair<int, List<Skill.Old.Data>> keyValuePair in data.specialSkillOldList)
- {
- foreach (Skill.Old.Data data2 in keyValuePair.Value)
- {
- if (num < this.specialSkillLabelList.Count)
- {
- this.specialSkillLabelList[num++].text = data2.name;
- if (this.specialSkillLabelList.Count == num)
- {
- this.specialSkillLabelList[num - 1].text = "etc...";
- }
- }
- if (this.specialSkillLabelList.Count == num)
- {
- break;
- }
- }
- if (this.specialSkillLabelList.Count == num)
- {
- break;
- }
- }
- }
- else
- {
- foreach (KeyValuePair<int, List<Skill.Data>> keyValuePair2 in data.specialSkillList)
- {
- foreach (Skill.Data data3 in keyValuePair2.Value)
- {
- if (num < this.specialSkillLabelList.Count)
- {
- UILabel uilabel2 = this.specialSkillLabelList[num++];
- uilabel2.text = data3.name;
- if (GameUty.supportMultiLanguage)
- {
- Localize component2 = uilabel2.GetComponent<Localize>();
- if (component2 != null)
- {
- component2.SetTerm(data3.termName);
- }
- }
- if (this.specialSkillLabelList.Count == num)
- {
- this.specialSkillLabelList[num - 1].text = "etc...";
- }
- }
- if (this.specialSkillLabelList.Count == num)
- {
- break;
- }
- }
- if (this.specialSkillLabelList.Count == num)
- {
- break;
- }
- }
- }
- this.specialSkillLabelsParent.SetActive(!string.IsNullOrEmpty(this.specialSkillLabelList[0].text));
- if (this.specialSkillLabelsParent.activeSelf)
- {
- UIWidget component3 = UTY.GetChildObject(this.specialSkillLabelsParent, "BG", false).GetComponent<UIWidget>();
- component3.height = 100 + 36 * num;
- }
- }
- else
- {
- this.OnHoverOutItem();
- }
- }
- private void OnHoverOutItem()
- {
- this.conditionsObject.SetActive(false);
- this.specialSkillLabelsParent.SetActive(false);
- }
- private GameObject CreateItemObject(Maid maid, int no, YotogiClassListManager.Data data)
- {
- GameObject gameObject;
- if (this.storageObject.transform.childCount == 0)
- {
- gameObject = this.InstantiateItem(this.storageObject);
- }
- else
- {
- gameObject = this.storageObject.transform.GetChild(0).gameObject;
- }
- gameObject.transform.SetParent(this.contentObject.transform, false);
- if (0 <= no)
- {
- gameObject.name = no.ToString("D4");
- }
- else
- {
- gameObject.name = "EX";
- }
- UILabel component = UTY.GetChildObject(gameObject, "Number/Value", false).GetComponent<UILabel>();
- if (0 <= no)
- {
- component.text = no.ToString();
- }
- else
- {
- component.text = "EX";
- }
- UILabel component2 = UTY.GetChildObject(gameObject, "SkillName/Value", false).GetComponent<UILabel>();
- component2.color = (data.isLearn ? Color.white : Color.gray);
- component2.text = data.classData.drawName;
- Localize component3 = component2.GetComponent<Localize>();
- if (component3 != null)
- {
- component3.SetTerm(data.classData.termName);
- }
- gameObject.GetComponent<BoxCollider>().enabled = !data.isLearn;
- return gameObject;
- }
- private void DeleteItemAllObject()
- {
- List<GameObject> list = new List<GameObject>();
- for (int i = 0; i < this.contentObject.transform.childCount; i++)
- {
- list.Add(this.contentObject.transform.GetChild(i).gameObject);
- }
- foreach (GameObject obj in list)
- {
- this.DeleteItemObject(obj);
- }
- }
- private void DeleteItemObject(GameObject obj)
- {
- if (obj.transform.parent != this.storageObject.transform)
- {
- obj.transform.SetParent(this.storageObject.transform, false);
- }
- }
- [SerializeField]
- private GameObject storageObject;
- [SerializeField]
- private GameObject contentObject;
- [SerializeField]
- private UIScrollView scrollView;
- [SerializeField]
- private GameObject conditionsObject;
- [SerializeField]
- private UILabel conditionTitleLabel;
- [SerializeField]
- private GameObject specialSkillLabelsParent;
- private UIGrid itemGrid;
- private UIWFConditionList conditionList;
- private UIWidget conditionBG;
- private List<UILabel> specialSkillLabelList;
- private Dictionary<int, KeyValuePair<string[], Color>[]> conditionDatas;
- private Dictionary<int, YotogiClassListManager.Data> instansToDatas;
- public class Data : IComparable, IComparable<YotogiClassListManager.Data>
- {
- public int CompareTo(YotogiClassListManager.Data other)
- {
- return this.classData.CompareTo(other.classData);
- }
- public int CompareTo(object other)
- {
- return this.classData.CompareTo(((YotogiClassListManager.Data)other).classData);
- }
- public YotogiClass.Data classData;
- public KeyValuePair<string[], bool>[] conditionDatas;
- public bool isLearn;
- public SortedList<int, List<Skill.Data>> specialSkillList;
- public SortedList<int, List<Skill.Old.Data>> specialSkillOldList;
- }
- }
|