YotogiClassListManager.cs 13 KB

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