YotogiClassListManager.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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 = GameUty.supportMultiLanguage ? 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 (GameUty.supportMultiLanguage)
  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. if (GameUty.supportMultiLanguage)
  249. {
  250. Localize component2 = uilabel2.GetComponent<Localize>();
  251. if (component2 != null)
  252. {
  253. component2.SetTerm(data3.termName);
  254. }
  255. }
  256. if (this.specialSkillLabelList.Count == num)
  257. {
  258. this.specialSkillLabelList[num - 1].text = "etc...";
  259. }
  260. }
  261. if (this.specialSkillLabelList.Count == num)
  262. {
  263. break;
  264. }
  265. }
  266. if (this.specialSkillLabelList.Count == num)
  267. {
  268. break;
  269. }
  270. }
  271. }
  272. this.specialSkillLabelsParent.SetActive(!string.IsNullOrEmpty(this.specialSkillLabelList[0].text));
  273. if (this.specialSkillLabelsParent.activeSelf)
  274. {
  275. UIWidget component3 = UTY.GetChildObject(this.specialSkillLabelsParent, "BG", false).GetComponent<UIWidget>();
  276. component3.height = 100 + 36 * num;
  277. }
  278. }
  279. else
  280. {
  281. this.OnHoverOutItem();
  282. }
  283. }
  284. private void OnHoverOutItem()
  285. {
  286. this.conditionsObject.SetActive(false);
  287. this.specialSkillLabelsParent.SetActive(false);
  288. }
  289. private GameObject CreateItemObject(Maid maid, int no, YotogiClassListManager.Data data)
  290. {
  291. GameObject gameObject;
  292. if (this.storageObject.transform.childCount == 0)
  293. {
  294. gameObject = this.InstantiateItem(this.storageObject);
  295. }
  296. else
  297. {
  298. gameObject = this.storageObject.transform.GetChild(0).gameObject;
  299. }
  300. gameObject.transform.SetParent(this.contentObject.transform, false);
  301. if (0 <= no)
  302. {
  303. gameObject.name = no.ToString("D4");
  304. }
  305. else
  306. {
  307. gameObject.name = "EX";
  308. }
  309. UILabel component = UTY.GetChildObject(gameObject, "Number/Value", false).GetComponent<UILabel>();
  310. if (0 <= no)
  311. {
  312. component.text = no.ToString();
  313. }
  314. else
  315. {
  316. component.text = "EX";
  317. }
  318. UILabel component2 = UTY.GetChildObject(gameObject, "SkillName/Value", false).GetComponent<UILabel>();
  319. component2.color = (data.isLearn ? Color.white : Color.gray);
  320. component2.text = data.classData.drawName;
  321. Localize component3 = component2.GetComponent<Localize>();
  322. if (component3 != null)
  323. {
  324. component3.SetTerm(data.classData.termName);
  325. }
  326. gameObject.GetComponent<BoxCollider>().enabled = !data.isLearn;
  327. return gameObject;
  328. }
  329. private void DeleteItemAllObject()
  330. {
  331. List<GameObject> list = new List<GameObject>();
  332. for (int i = 0; i < this.contentObject.transform.childCount; i++)
  333. {
  334. list.Add(this.contentObject.transform.GetChild(i).gameObject);
  335. }
  336. foreach (GameObject obj in list)
  337. {
  338. this.DeleteItemObject(obj);
  339. }
  340. }
  341. private void DeleteItemObject(GameObject obj)
  342. {
  343. if (obj.transform.parent != this.storageObject.transform)
  344. {
  345. obj.transform.SetParent(this.storageObject.transform, false);
  346. }
  347. }
  348. [SerializeField]
  349. private GameObject storageObject;
  350. [SerializeField]
  351. private GameObject contentObject;
  352. [SerializeField]
  353. private UIScrollView scrollView;
  354. [SerializeField]
  355. private GameObject conditionsObject;
  356. [SerializeField]
  357. private UILabel conditionTitleLabel;
  358. [SerializeField]
  359. private GameObject specialSkillLabelsParent;
  360. private UIGrid itemGrid;
  361. private UIWFConditionList conditionList;
  362. private UIWidget conditionBG;
  363. private List<UILabel> specialSkillLabelList;
  364. private Dictionary<int, KeyValuePair<string[], Color>[]> conditionDatas;
  365. private Dictionary<int, YotogiClassListManager.Data> instansToDatas;
  366. public class Data : IComparable, IComparable<YotogiClassListManager.Data>
  367. {
  368. public int CompareTo(YotogiClassListManager.Data other)
  369. {
  370. return this.classData.CompareTo(other.classData);
  371. }
  372. public int CompareTo(object other)
  373. {
  374. return this.classData.CompareTo(((YotogiClassListManager.Data)other).classData);
  375. }
  376. public YotogiClass.Data classData;
  377. public KeyValuePair<string[], bool>[] conditionDatas;
  378. public bool isLearn;
  379. public SortedList<int, List<Skill.Data>> specialSkillList;
  380. public SortedList<int, List<Skill.Old.Data>> specialSkillOldList;
  381. }
  382. }