YotogiClassListManager.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. using System;
  2. using System.Collections.Generic;
  3. using MaidStatus;
  4. using MaidStatus.CsvData;
  5. using UnityEngine;
  6. using wf;
  7. using Yotogis;
  8. public class YotogiClassListManager : MonoBehaviour
  9. {
  10. public static List<YotogiClassListManager.Data> CreateDatas(Status status)
  11. {
  12. List<YotogiClass.Data> list = new List<YotogiClass.Data>();
  13. foreach (YotogiClass.Data data in YotogiClass.GetAllDatas(true))
  14. {
  15. if (data.learnConditions.isLearnPossiblePersonal(status.personal) && data.classType != AbstractClassData.ClassType.Old)
  16. {
  17. list.Add(data);
  18. }
  19. }
  20. return YotogiClassListManager.CreateDatas(list, status);
  21. }
  22. public static List<YotogiClassListManager.Data> CreateDatasOld(Status status)
  23. {
  24. List<YotogiClass.Data> list = new List<YotogiClass.Data>();
  25. foreach (YotogiClass.Data data in YotogiClass.GetAllDatas(true))
  26. {
  27. if (data.learnConditions.isLearnPossiblePersonal(status.personal) && data.classType != AbstractClassData.ClassType.New)
  28. {
  29. list.Add(data);
  30. }
  31. }
  32. return YotogiClassListManager.CreateDatas(list, status);
  33. }
  34. private static List<YotogiClassListManager.Data> CreateDatas(List<YotogiClass.Data> datas, Status status)
  35. {
  36. List<YotogiClassListManager.Data> list = new List<YotogiClassListManager.Data>();
  37. List<KeyValuePair<string, bool>> list2 = new List<KeyValuePair<string, bool>>();
  38. foreach (YotogiClass.Data data in datas)
  39. {
  40. list2 = data.learnConditions.CreateConditionTextAndStaturResults(status);
  41. YotogiClassListManager.Data data2 = new YotogiClassListManager.Data();
  42. data2.classData = data;
  43. data2.isLearn = status.yotogiClass.Contains(data2.classData);
  44. data2.conditionDatas = list2.ToArray();
  45. data2.specialSkillList = YotogiClass.GetLearnSkillList(data2.classData.id);
  46. data2.specialSkillOldList = YotogiClass.GetLearnSkillOldList(data2.classData.id);
  47. list.Add(data2);
  48. }
  49. list.Sort();
  50. return list;
  51. }
  52. private void Awake()
  53. {
  54. if (this.conditionDatas != null)
  55. {
  56. return;
  57. }
  58. this.itemGrid = this.contentObject.GetComponent<UIGrid>();
  59. NDebug.AssertNull(this.itemGrid != null);
  60. this.conditionList = this.conditionsObject.GetComponentInChildren<UIWFConditionList>();
  61. NDebug.AssertNull(this.conditionList != null);
  62. this.conditionBG = UTY.GetChildObject(this.conditionsObject, "BG", false).GetComponent<UIWidget>();
  63. for (int i = 0; i < 50; i++)
  64. {
  65. this.InstantiateItem(this.storageObject);
  66. }
  67. this.conditionDatas = new Dictionary<int, KeyValuePair<string, Color>[]>();
  68. this.instansToDatas = new Dictionary<int, YotogiClassListManager.Data>();
  69. this.conditionsObject.SetActive(false);
  70. this.specialSkillLabelsParent.SetActive(false);
  71. this.specialSkillLabelList = new List<UILabel>(UTY.GetChildObject(this.specialSkillLabelsParent, "UnitParent", false).GetComponentsInChildren<UILabel>());
  72. ClassChangePanel.CreateClassText();
  73. }
  74. public void CreateData(Maid maid)
  75. {
  76. if (this.conditionDatas == null)
  77. {
  78. this.Awake();
  79. }
  80. this.DeleteItemAllObject();
  81. this.conditionDatas.Clear();
  82. this.instansToDatas.Clear();
  83. Utility.ResetNGUI(this.itemGrid);
  84. Utility.ResetNGUI(this.scrollView);
  85. bool lockNTRPlay = GameMain.Instance.CharacterMgr.status.lockNTRPlay;
  86. List<KeyValuePair<string, Color>> list = new List<KeyValuePair<string, Color>>();
  87. int num = 0;
  88. List<YotogiClassListManager.Data> list2;
  89. if (MaidManagement.compatibilityMode)
  90. {
  91. list2 = YotogiClassListManager.CreateDatasOld(maid.status);
  92. }
  93. else
  94. {
  95. list2 = YotogiClassListManager.CreateDatas(maid.status);
  96. }
  97. List<YotogiClassListManager.Data> list3 = new List<YotogiClassListManager.Data>();
  98. foreach (YotogiClassListManager.Data data in list2)
  99. {
  100. if (!lockNTRPlay || !YotogiClass.IsNTRClass(data.classData.id, MaidManagement.compatibilityMode))
  101. {
  102. if (data.classData.learnConditions.isSpecialConditions())
  103. {
  104. AbstractClassData.LearnConditions learnConditions = data.classData.learnConditions;
  105. if (data.isLearn && !learnConditions.CheckSpecialConditions(maid.status))
  106. {
  107. continue;
  108. }
  109. if (!data.isLearn && !learnConditions.isFutureLearnPossible(maid.status))
  110. {
  111. continue;
  112. }
  113. }
  114. if (data.classData != null && data.classData.learnConditions.requestPersonals.Count != 0 && data.classData.classType != AbstractClassData.ClassType.Old)
  115. {
  116. list3.Add(data);
  117. }
  118. else
  119. {
  120. GameObject gameObject = this.CreateItemObject(maid, ++num, data);
  121. if (0 < data.conditionDatas.Length)
  122. {
  123. List<KeyValuePair<string, Color>> list4 = new List<KeyValuePair<string, Color>>();
  124. foreach (KeyValuePair<string, bool> keyValuePair in data.conditionDatas)
  125. {
  126. list4.Add(new KeyValuePair<string, Color>(keyValuePair.Key, (!keyValuePair.Value) ? Color.gray : Color.white));
  127. }
  128. this.conditionDatas.Add(gameObject.GetInstanceID(), list4.ToArray());
  129. this.instansToDatas.Add(gameObject.GetInstanceID(), data);
  130. }
  131. }
  132. }
  133. }
  134. foreach (YotogiClassListManager.Data data2 in list3)
  135. {
  136. GameObject gameObject2 = this.CreateItemObject(maid, -1, data2);
  137. if (0 < data2.conditionDatas.Length)
  138. {
  139. List<KeyValuePair<string, Color>> list5 = new List<KeyValuePair<string, Color>>();
  140. if (data2.classData != null)
  141. {
  142. foreach (int num2 in data2.classData.learnConditions.requestPersonals)
  143. {
  144. if (maid.status.personal.id == num2)
  145. {
  146. list5.Add(new KeyValuePair<string, Color>("ヒロインタイプ " + maid.status.personal.drawName, Color.white));
  147. break;
  148. }
  149. }
  150. }
  151. foreach (KeyValuePair<string, bool> keyValuePair2 in data2.conditionDatas)
  152. {
  153. list5.Add(new KeyValuePair<string, Color>(keyValuePair2.Key, (!keyValuePair2.Value) ? Color.gray : Color.white));
  154. }
  155. this.conditionDatas.Add(gameObject2.GetInstanceID(), list5.ToArray());
  156. this.instansToDatas.Add(gameObject2.GetInstanceID(), data2);
  157. }
  158. }
  159. Utility.ResetNGUI(this.itemGrid);
  160. Utility.ResetNGUI(this.scrollView);
  161. }
  162. private void OnEnable()
  163. {
  164. Utility.ResetNGUI(this.itemGrid);
  165. Utility.ResetNGUI(this.scrollView);
  166. this.OnHoverOutItem();
  167. }
  168. private GameObject InstantiateItem(GameObject parent)
  169. {
  170. GameObject gameObject = Utility.CreatePrefab(parent, "SceneEdit/Profile/Prefab/ProfileYotogiSkillItemSimple", true);
  171. UIEventTrigger component = gameObject.GetComponent<UIEventTrigger>();
  172. EventDelegate eventDelegate = new EventDelegate(this, "OnHoverOverItem");
  173. eventDelegate.parameters[0].value = gameObject.GetInstanceID();
  174. EventDelegate.Add(component.onHoverOver, eventDelegate);
  175. EventDelegate.Add(component.onHoverOut, new EventDelegate.Callback(this.OnHoverOutItem));
  176. return gameObject;
  177. }
  178. private void OnHoverOverItem(int instanceId)
  179. {
  180. if (this.conditionDatas.ContainsKey(instanceId))
  181. {
  182. YotogiClassListManager.Data data = this.instansToDatas[instanceId];
  183. this.conditionTitleLabel.text = data.classData.drawName + " 取得条件";
  184. this.conditionList.SetTexts(this.conditionDatas[instanceId], 500);
  185. this.conditionBG.height = 90 + this.conditionList.height;
  186. this.conditionsObject.SetActive(true);
  187. foreach (UILabel uilabel in this.specialSkillLabelList)
  188. {
  189. uilabel.text = string.Empty;
  190. }
  191. int num = 0;
  192. if (MaidManagement.compatibilityMode)
  193. {
  194. foreach (KeyValuePair<int, List<Skill.Old.Data>> keyValuePair in data.specialSkillOldList)
  195. {
  196. foreach (Skill.Old.Data data2 in keyValuePair.Value)
  197. {
  198. if (num < this.specialSkillLabelList.Count)
  199. {
  200. this.specialSkillLabelList[num++].text = data2.name;
  201. if (this.specialSkillLabelList.Count == num)
  202. {
  203. this.specialSkillLabelList[num - 1].text = "etc...";
  204. }
  205. }
  206. if (this.specialSkillLabelList.Count == num)
  207. {
  208. break;
  209. }
  210. }
  211. if (this.specialSkillLabelList.Count == num)
  212. {
  213. break;
  214. }
  215. }
  216. }
  217. else
  218. {
  219. foreach (KeyValuePair<int, List<Skill.Data>> keyValuePair2 in data.specialSkillList)
  220. {
  221. foreach (Skill.Data data3 in keyValuePair2.Value)
  222. {
  223. if (num < this.specialSkillLabelList.Count)
  224. {
  225. this.specialSkillLabelList[num++].text = data3.name;
  226. if (this.specialSkillLabelList.Count == num)
  227. {
  228. this.specialSkillLabelList[num - 1].text = "etc...";
  229. }
  230. }
  231. if (this.specialSkillLabelList.Count == num)
  232. {
  233. break;
  234. }
  235. }
  236. if (this.specialSkillLabelList.Count == num)
  237. {
  238. break;
  239. }
  240. }
  241. }
  242. this.specialSkillLabelsParent.SetActive(!string.IsNullOrEmpty(this.specialSkillLabelList[0].text));
  243. if (this.specialSkillLabelsParent.activeSelf)
  244. {
  245. UIWidget component = UTY.GetChildObject(this.specialSkillLabelsParent, "BG", false).GetComponent<UIWidget>();
  246. component.height = 100 + 36 * num;
  247. }
  248. }
  249. else
  250. {
  251. this.OnHoverOutItem();
  252. }
  253. }
  254. private void OnHoverOutItem()
  255. {
  256. this.conditionsObject.SetActive(false);
  257. this.specialSkillLabelsParent.SetActive(false);
  258. }
  259. private GameObject CreateItemObject(Maid maid, int no, YotogiClassListManager.Data data)
  260. {
  261. GameObject gameObject;
  262. if (this.storageObject.transform.childCount == 0)
  263. {
  264. gameObject = this.InstantiateItem(this.storageObject);
  265. }
  266. else
  267. {
  268. gameObject = this.storageObject.transform.GetChild(0).gameObject;
  269. }
  270. gameObject.transform.SetParent(this.contentObject.transform, false);
  271. if (0 <= no)
  272. {
  273. gameObject.name = no.ToString("D4");
  274. }
  275. else
  276. {
  277. gameObject.name = "EX";
  278. }
  279. UILabel component = UTY.GetChildObject(gameObject, "Number/Value", false).GetComponent<UILabel>();
  280. if (0 <= no)
  281. {
  282. component.text = no.ToString();
  283. }
  284. else
  285. {
  286. component.text = "EX";
  287. }
  288. UILabel component2 = UTY.GetChildObject(gameObject, "SkillName/Value", false).GetComponent<UILabel>();
  289. component2.text = data.classData.drawName;
  290. component2.color = (data.isLearn ? Color.white : Color.gray);
  291. gameObject.GetComponent<BoxCollider>().enabled = !data.isLearn;
  292. return gameObject;
  293. }
  294. private void DeleteItemAllObject()
  295. {
  296. List<GameObject> list = new List<GameObject>();
  297. for (int i = 0; i < this.contentObject.transform.childCount; i++)
  298. {
  299. list.Add(this.contentObject.transform.GetChild(i).gameObject);
  300. }
  301. foreach (GameObject obj in list)
  302. {
  303. this.DeleteItemObject(obj);
  304. }
  305. }
  306. private void DeleteItemObject(GameObject obj)
  307. {
  308. if (obj.transform.parent != this.storageObject.transform)
  309. {
  310. obj.transform.SetParent(this.storageObject.transform, false);
  311. }
  312. }
  313. [SerializeField]
  314. private GameObject storageObject;
  315. [SerializeField]
  316. private GameObject contentObject;
  317. [SerializeField]
  318. private UIScrollView scrollView;
  319. [SerializeField]
  320. private GameObject conditionsObject;
  321. [SerializeField]
  322. private UILabel conditionTitleLabel;
  323. [SerializeField]
  324. private GameObject specialSkillLabelsParent;
  325. private UIGrid itemGrid;
  326. private UIWFConditionList conditionList;
  327. private UIWidget conditionBG;
  328. private List<UILabel> specialSkillLabelList;
  329. private Dictionary<int, KeyValuePair<string, Color>[]> conditionDatas;
  330. private Dictionary<int, YotogiClassListManager.Data> instansToDatas;
  331. public class Data : IComparable, IComparable<YotogiClassListManager.Data>
  332. {
  333. public int CompareTo(YotogiClassListManager.Data other)
  334. {
  335. return this.classData.CompareTo(other.classData);
  336. }
  337. public int CompareTo(object other)
  338. {
  339. return this.classData.CompareTo(((YotogiClassListManager.Data)other).classData);
  340. }
  341. public YotogiClass.Data classData;
  342. public KeyValuePair<string, bool>[] conditionDatas;
  343. public bool isLearn;
  344. public SortedList<int, List<Skill.Data>> specialSkillList;
  345. public SortedList<int, List<Skill.Old.Data>> specialSkillOldList;
  346. }
  347. }