using System; using System.Collections.Generic; using MaidStatus; using MaidStatus.CsvData; using UnityEngine; using wf; using Yotogis; public class YotogiClassListManager : MonoBehaviour { public static List CreateDatas(Status status) { List list = new List(); 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 CreateDatasOld(Status status) { List list = new List(); 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 CreateDatas(List datas, Status status) { List list = new List(); List> list2 = new List>(); 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(); NDebug.AssertNull(this.itemGrid != null); this.conditionList = this.conditionsObject.GetComponentInChildren(); NDebug.AssertNull(this.conditionList != null); this.conditionBG = UTY.GetChildObject(this.conditionsObject, "BG", false).GetComponent(); for (int i = 0; i < 50; i++) { this.InstantiateItem(this.storageObject); } this.conditionDatas = new Dictionary[]>(); this.instansToDatas = new Dictionary(); this.conditionsObject.SetActive(false); this.specialSkillLabelsParent.SetActive(false); this.specialSkillLabelList = new List(UTY.GetChildObject(this.specialSkillLabelsParent, "UnitParent", false).GetComponentsInChildren()); 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> list = new List>(); int num = 0; List list2; if (MaidManagement.compatibilityMode) { list2 = YotogiClassListManager.CreateDatasOld(maid.status); } else { list2 = YotogiClassListManager.CreateDatas(maid.status); } List list3 = new List(); 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> list4 = new List>(); foreach (KeyValuePair keyValuePair in data.conditionDatas) { list4.Add(new KeyValuePair(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> list5 = new List>(); if (data2.classData != null) { foreach (int num2 in data2.classData.learnConditions.requestPersonals) { if (maid.status.personal.id == num2) { list5.Add(new KeyValuePair("ヒロインタイプ " + maid.status.personal.drawName, Color.white)); break; } } } foreach (KeyValuePair keyValuePair2 in data2.conditionDatas) { list5.Add(new KeyValuePair(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(); 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 + " 取得条件"; 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> 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> keyValuePair2 in data.specialSkillList) { foreach (Skill.Data data3 in keyValuePair2.Value) { if (num < this.specialSkillLabelList.Count) { this.specialSkillLabelList[num++].text = data3.name; 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 component = UTY.GetChildObject(this.specialSkillLabelsParent, "BG", false).GetComponent(); component.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(); if (0 <= no) { component.text = no.ToString(); } else { component.text = "EX"; } UILabel component2 = UTY.GetChildObject(gameObject, "SkillName/Value", false).GetComponent(); component2.text = data.classData.drawName; component2.color = (data.isLearn ? Color.white : Color.gray); gameObject.GetComponent().enabled = !data.isLearn; return gameObject; } private void DeleteItemAllObject() { List list = new List(); 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 specialSkillLabelList; private Dictionary[]> conditionDatas; private Dictionary instansToDatas; public class Data : IComparable, IComparable { 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[] conditionDatas; public bool isLearn; public SortedList> specialSkillList; public SortedList> specialSkillOldList; } }