YotogiClassListManager.cs 12 KB

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