ClassChangePanel.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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 ClassChangePanel : MonoBehaviour
  9. {
  10. public static void CreateClassText()
  11. {
  12. if (ClassChangePanel.job_class_special_skill_list_.Count != 0)
  13. {
  14. return;
  15. }
  16. foreach (JobClass.Data data in JobClass.GetAllDatas(false))
  17. {
  18. ClassChangePanel.job_class_special_skill_list_.Add(data.id, new SortedList<int, List<Skill.Data>>());
  19. }
  20. }
  21. public void Awake()
  22. {
  23. if (this.job_class_unit_dic_.Count != 0)
  24. {
  25. return;
  26. }
  27. this.class_type_tab_panel_ = UTY.GetChildObject(base.gameObject, "ClassViewer/TabButton", false).GetComponent<UIWFTabPanel>();
  28. this.job_class_button_ = UTY.GetChildObject(base.gameObject, "ClassViewer/TabButton/MaidClass", false).GetComponent<UIWFTabButton>();
  29. this.info_panel_item_.class_name = UTY.GetChildObject(base.gameObject, "ClassViewer/Common/ClassDescription/ClassName", false).GetComponent<UILabel>();
  30. this.info_panel_item_.class_level = UTY.GetChildObject(base.gameObject, "ClassViewer/Common/ClassDescription/LevelGroup/Level/Value", false).GetComponent<UILabel>();
  31. this.info_panel_item_.current_exp = UTY.GetChildObject(base.gameObject, "ClassViewer/Common/ClassDescription/LevelGroup/Exp/Value", false).GetComponent<UILabel>();
  32. this.info_panel_item_.next_exp = UTY.GetChildObject(base.gameObject, "ClassViewer/Common/ClassDescription/LevelGroup/RequiredExp/Value", false).GetComponent<UILabel>();
  33. this.info_panel_item_.info_text = UTY.GetChildObject(base.gameObject, "ClassViewer/Common/ClassDescription/Description", false).GetComponent<UILabel>();
  34. this.info_panel_item_.special_skill = new List<UILabel>();
  35. GameObject childObject = UTY.GetChildObject(base.gameObject, "ClassViewer/Yotogi/SkillList/Contents/UnitParent", false);
  36. int childCount = childObject.transform.childCount;
  37. for (int i = 0; i < childCount; i++)
  38. {
  39. this.info_panel_item_.special_skill.Add(childObject.transform.GetChild(i).gameObject.GetComponent<UILabel>());
  40. }
  41. this.jobUIs = new ClassChangePanel.UISet();
  42. this.jobUIs.selectButton = UTY.GetChildObject(this.class_type_tab_panel_.gameObject, "MaidClass", false).GetComponent<UIWFTabButton>();
  43. this.jobUIs.classListObject = UTY.GetChildObject(base.gameObject, "ClassViewer/Common/ClassListMaid", false);
  44. this.jobUIs.itemGrid = UTY.GetChildObject(this.jobUIs.classListObject, "Contents/UnitParent", false).GetComponent<UIGrid>();
  45. this.jobUIs.scrollView = UTY.GetChildObject(this.jobUIs.classListObject, "Contents", false).GetComponent<UIScrollView>();
  46. this.jobUIs.tabPanel = this.jobUIs.classListObject.GetComponentInChildren<UIWFTabPanel>();
  47. this.jobUIs.classListObject.SetActive(true);
  48. List<JobClass.Data> allDatas = JobClass.GetAllDatas(true);
  49. allDatas.Sort();
  50. foreach (JobClass.Data data in allDatas)
  51. {
  52. ClassUnit component = Utility.CreatePrefab(this.jobUIs.itemGrid.gameObject, "SceneCompetitiveShow/Prefab/ClassUnit", true).GetComponent<ClassUnit>();
  53. component.SetJobClassType(data.id);
  54. component.SetClassChangePanel(this);
  55. component.SetOnSelectEvent(new Action<ClassUnit>(this.OnSelectClassUnitEvent));
  56. UIEventTrigger[] componentsInChildren = component.GetComponentsInChildren<UIEventTrigger>();
  57. EventDelegate eventDelegate = new EventDelegate(this, "OnUnitMouseHoverIn");
  58. eventDelegate.parameters[0].value = component;
  59. foreach (UIEventTrigger uieventTrigger in componentsInChildren)
  60. {
  61. EventDelegate.Add(uieventTrigger.onHoverOver, eventDelegate);
  62. EventDelegate.Add(uieventTrigger.onHoverOut, new EventDelegate.Callback(this.OnUnitMouseHoverOut));
  63. }
  64. this.job_class_unit_dic_.Add(data.id, component);
  65. }
  66. this.jobUIs.tabPanel.UpdateChildren();
  67. this.jobUIs.itemGrid.repositionNow = true;
  68. EventDelegate.Add(this.jobUIs.selectButton.onSelect, new EventDelegate.Callback(this.OnSelectType));
  69. this.jobUIs.classListObject.SetActive(false);
  70. this.yotogiUIs = new ClassChangePanel.UISet();
  71. this.yotogiUIs.selectButton = UTY.GetChildObject(this.class_type_tab_panel_.gameObject, "YotogiClass", false).GetComponent<UIWFTabButton>();
  72. this.yotogiUIs.classListObject = UTY.GetChildObject(base.gameObject, "ClassViewer/Common/ClassListYotogi", false);
  73. this.yotogiUIs.itemGrid = UTY.GetChildObject(this.yotogiUIs.classListObject, "Contents/UnitParent", false).GetComponent<UIGrid>();
  74. this.yotogiUIs.scrollView = UTY.GetChildObject(this.yotogiUIs.classListObject, "Contents", false).GetComponent<UIScrollView>();
  75. this.yotogiUIs.tabPanel = this.yotogiUIs.classListObject.GetComponentInChildren<UIWFTabPanel>();
  76. this.yotogiUIs.classListObject.SetActive(true);
  77. foreach (YotogiClass.Data data2 in YotogiClass.GetAllDatas(true))
  78. {
  79. ClassUnit component2 = Utility.CreatePrefab(this.yotogiUIs.itemGrid.gameObject, "SceneCompetitiveShow/Prefab/ClassUnit", true).GetComponent<ClassUnit>();
  80. component2.SetYotogiClassType(data2.id);
  81. component2.SetClassChangePanel(this);
  82. component2.SetOnSelectEvent(new Action<ClassUnit>(this.OnSelectClassUnitEvent));
  83. UIEventTrigger[] componentsInChildren2 = component2.GetComponentsInChildren<UIEventTrigger>();
  84. EventDelegate eventDelegate2 = new EventDelegate(this, "OnUnitMouseHoverIn");
  85. eventDelegate2.parameters[0].value = component2;
  86. foreach (UIEventTrigger uieventTrigger2 in componentsInChildren2)
  87. {
  88. EventDelegate.Add(uieventTrigger2.onHoverOver, eventDelegate2);
  89. EventDelegate.Add(uieventTrigger2.onHoverOut, new EventDelegate.Callback(this.OnUnitMouseHoverOut));
  90. }
  91. this.yotogi_class_unit_dic_.Add(data2.id, component2);
  92. }
  93. this.yotogiUIs.tabPanel.UpdateChildren();
  94. this.yotogiUIs.itemGrid.repositionNow = true;
  95. EventDelegate.Add(this.yotogiUIs.selectButton.onSelect, new EventDelegate.Callback(this.OnSelectType));
  96. this.yotogiUIs.classListObject.SetActive(false);
  97. ClassChangePanel.CreateClassText();
  98. this.class_type_tab_panel_.gameObject.SetActive(false);
  99. }
  100. public void OnEnable()
  101. {
  102. this.jobUIs.Reset();
  103. this.yotogiUIs.Reset();
  104. }
  105. public void SetTargetMaid(Maid maid)
  106. {
  107. if (this.job_class_unit_dic_.Count == 0)
  108. {
  109. bool activeSelf = base.gameObject.activeSelf;
  110. base.gameObject.SetActive(true);
  111. this.Awake();
  112. base.gameObject.SetActive(activeSelf);
  113. }
  114. this.maid_ = maid;
  115. Status status = this.maid_.status;
  116. foreach (KeyValuePair<int, ClassUnit> keyValuePair in this.job_class_unit_dic_)
  117. {
  118. keyValuePair.Value.UpdateMaidData(this.maid_);
  119. }
  120. this.jobUIs.tabPanel.ResetSelect();
  121. foreach (KeyValuePair<int, ClassUnit> keyValuePair2 in this.job_class_unit_dic_)
  122. {
  123. ClassUnit value = keyValuePair2.Value;
  124. value.button.SetSelect(false);
  125. value.button.isEnabled = status.jobClass.Contains(value.maid_class_type);
  126. JobClass.Data data = JobClass.GetData(value.maid_class_type);
  127. if (MaidManagement.compatibilityMode)
  128. {
  129. value.gameObject.SetActive(data.classType != AbstractClassData.ClassType.New);
  130. }
  131. else
  132. {
  133. value.gameObject.SetActive(data.classType != AbstractClassData.ClassType.Old);
  134. }
  135. if (value.gameObject.activeSelf)
  136. {
  137. value.gameObject.SetActive(data.learnConditions.isLearnPossiblePersonal(maid.status.personal));
  138. }
  139. }
  140. GameObject gameObject = this.yotogiUIs.itemGrid.gameObject;
  141. while (gameObject.transform.parent != null && !gameObject.transform.gameObject.activeInHierarchy)
  142. {
  143. gameObject = ((!(gameObject.transform.parent != null)) ? null : gameObject.transform.parent.gameObject);
  144. }
  145. if (gameObject != null)
  146. {
  147. gameObject.SetActive(true);
  148. }
  149. this.jobUIs.Reset();
  150. int num = (status.selectedJobClass == null) ? int.MinValue : status.selectedJobClass.data.id;
  151. if (num != -2147483648)
  152. {
  153. this.jobUIs.tabPanel.Select(this.job_class_unit_dic_[num].button);
  154. if (this.jobUIs.classListObject.activeSelf)
  155. {
  156. this.job_class_unit_dic_[num].UpdateInfo();
  157. }
  158. }
  159. foreach (KeyValuePair<int, ClassUnit> keyValuePair3 in this.yotogi_class_unit_dic_)
  160. {
  161. keyValuePair3.Value.UpdateMaidData(this.maid_);
  162. }
  163. this.yotogiUIs.tabPanel.ResetSelect();
  164. foreach (KeyValuePair<int, ClassUnit> keyValuePair4 in this.yotogi_class_unit_dic_)
  165. {
  166. ClassUnit value2 = keyValuePair4.Value;
  167. value2.button.SetSelect(false);
  168. value2.button.isEnabled = status.yotogiClass.Contains(value2.yotogi_class_type);
  169. YotogiClass.Data data2 = YotogiClass.GetData(value2.yotogi_class_type);
  170. value2.gameObject.SetActive(data2.learnConditions.isLearnPossiblePersonal(maid.status.personal));
  171. }
  172. gameObject = this.yotogiUIs.itemGrid.gameObject;
  173. while (gameObject.transform.parent != null && !gameObject.transform.gameObject.activeInHierarchy)
  174. {
  175. gameObject = ((!(gameObject.transform.parent != null)) ? null : gameObject.transform.parent.gameObject);
  176. }
  177. if (gameObject != null)
  178. {
  179. gameObject.SetActive(true);
  180. }
  181. this.yotogiUIs.Reset();
  182. num = ((status.selectedYotogiClass == null) ? int.MinValue : status.selectedYotogiClass.data.id);
  183. if (num != -2147483648)
  184. {
  185. this.yotogiUIs.tabPanel.Select(this.yotogi_class_unit_dic_[num].button);
  186. if (this.yotogiUIs.classListObject.activeSelf)
  187. {
  188. this.yotogi_class_unit_dic_[num].UpdateInfo();
  189. }
  190. }
  191. if (this.class_type_tab_panel_.GetSelectButtonObject() == null)
  192. {
  193. this.class_type_tab_panel_.Select(this.job_class_button_);
  194. }
  195. }
  196. private void OnSelectType()
  197. {
  198. if (!UIWFSelectButton.current.isSelected)
  199. {
  200. return;
  201. }
  202. this.jobUIs.classListObject.SetActive(true);
  203. this.yotogiUIs.classListObject.SetActive(false);
  204. this.jobUIs.Reset();
  205. if (this.maid_ != null && this.maid_.status.selectedJobClass != null)
  206. {
  207. this.job_class_unit_dic_[this.maid_.status.selectedJobClass.data.id].UpdateInfo();
  208. }
  209. }
  210. public void SetInfoData(int maid_class_type)
  211. {
  212. if (this.maid_ == null)
  213. {
  214. return;
  215. }
  216. JobClass.Data data = JobClass.GetData(maid_class_type);
  217. ClassData<JobClass.Data> classData = this.maid_.status.jobClass.Get(maid_class_type);
  218. this.info_panel_item_.class_name.text = data.drawName;
  219. Utility.SetLocalizeTerm(this.info_panel_item_.class_name, data.termName, false);
  220. this.info_panel_item_.info_text.text = data.explanatoryText;
  221. Utility.SetLocalizeTerm(this.info_panel_item_.info_text, data.termExplanatoryText, false);
  222. if (classData != null)
  223. {
  224. this.info_panel_item_.class_level.text = classData.level.ToString();
  225. this.info_panel_item_.current_exp.text = classData.cur_exp.ToString();
  226. this.info_panel_item_.next_exp.text = classData.next_exp.ToString();
  227. }
  228. else
  229. {
  230. this.info_panel_item_.class_level.text = "-";
  231. this.info_panel_item_.current_exp.text = "-";
  232. this.info_panel_item_.next_exp.text = "-";
  233. }
  234. string[] array = new string[this.info_panel_item_.special_skill.Count];
  235. int num = 0;
  236. foreach (KeyValuePair<int, List<Skill.Data>> keyValuePair in ClassChangePanel.job_class_special_skill_list_[maid_class_type])
  237. {
  238. foreach (Skill.Data data2 in keyValuePair.Value)
  239. {
  240. if (num < array.Length)
  241. {
  242. array[num++] = data2.name;
  243. if (array.Length == num)
  244. {
  245. array[num - 1] = "etc...";
  246. }
  247. }
  248. if (array.Length == num)
  249. {
  250. break;
  251. }
  252. }
  253. if (array.Length == num)
  254. {
  255. break;
  256. }
  257. }
  258. for (int i = 0; i < array.Length; i++)
  259. {
  260. if (string.IsNullOrEmpty(array[i]))
  261. {
  262. this.info_panel_item_.special_skill[i].gameObject.SetActive(false);
  263. }
  264. else
  265. {
  266. this.info_panel_item_.special_skill[i].gameObject.SetActive(true);
  267. this.info_panel_item_.special_skill[i].text = array[i];
  268. }
  269. }
  270. }
  271. public void SetInfoDataYotogi(int yotogi_class_type)
  272. {
  273. if (this.maid_ == null)
  274. {
  275. return;
  276. }
  277. YotogiClass.Data data = YotogiClass.GetData(yotogi_class_type);
  278. ClassData<YotogiClass.Data> classData = this.maid_.status.yotogiClass.Get(yotogi_class_type);
  279. this.info_panel_item_.class_name.text = data.drawName;
  280. this.info_panel_item_.info_text.text = data.explanatoryText;
  281. if (classData != null)
  282. {
  283. this.info_panel_item_.class_level.text = classData.level.ToString();
  284. this.info_panel_item_.current_exp.text = classData.cur_exp.ToString();
  285. this.info_panel_item_.next_exp.text = classData.next_exp.ToString();
  286. }
  287. else
  288. {
  289. this.info_panel_item_.class_level.text = "-";
  290. this.info_panel_item_.current_exp.text = "-";
  291. this.info_panel_item_.next_exp.text = "-";
  292. }
  293. string[] array = new string[this.info_panel_item_.special_skill.Count];
  294. int num = 0;
  295. foreach (KeyValuePair<int, List<Skill.Data>> keyValuePair in YotogiClass.GetLearnSkillList(yotogi_class_type))
  296. {
  297. foreach (Skill.Data data2 in keyValuePair.Value)
  298. {
  299. if (num < array.Length)
  300. {
  301. array[num++] = data2.name;
  302. if (array.Length == num)
  303. {
  304. array[num - 1] = "etc...";
  305. }
  306. }
  307. if (array.Length == num)
  308. {
  309. break;
  310. }
  311. }
  312. if (array.Length == num)
  313. {
  314. break;
  315. }
  316. }
  317. for (int i = 0; i < array.Length; i++)
  318. {
  319. if (string.IsNullOrEmpty(array[i]))
  320. {
  321. this.info_panel_item_.special_skill[i].gameObject.SetActive(false);
  322. }
  323. else
  324. {
  325. this.info_panel_item_.special_skill[i].gameObject.SetActive(true);
  326. this.info_panel_item_.special_skill[i].text = array[i];
  327. }
  328. }
  329. }
  330. private void OnSelectClassUnitEvent(ClassUnit unit)
  331. {
  332. if (this.maid_ == null)
  333. {
  334. return;
  335. }
  336. if (unit.maid_class_type != -2147483648)
  337. {
  338. if (this.maid_.status.selectedJobClass.data.id != unit.maid_class_type)
  339. {
  340. this.maid_.status.ChangeJobClass(unit.maid_class_type);
  341. }
  342. }
  343. else if (unit.yotogi_class_type != -2147483648 && this.maid_.status.selectedYotogiClass.data.id != unit.yotogi_class_type)
  344. {
  345. this.maid_.status.ChangeYotogiClass(unit.yotogi_class_type);
  346. }
  347. }
  348. private void OnUnitMouseHoverIn(ClassUnit class_unit)
  349. {
  350. class_unit.UpdateInfo();
  351. }
  352. private void OnUnitMouseHoverOut()
  353. {
  354. if (this.jobUIs.classListObject.activeSelf)
  355. {
  356. if (this.maid_ != null && this.maid_.status.selectedJobClass != null && this.job_class_unit_dic_.ContainsKey(this.maid_.status.selectedJobClass.data.id))
  357. {
  358. this.job_class_unit_dic_[this.maid_.status.selectedJobClass.data.id].UpdateInfo();
  359. }
  360. }
  361. else if (this.maid_ != null && this.maid_.status.selectedYotogiClass != null && this.yotogi_class_unit_dic_.ContainsKey(this.maid_.status.selectedYotogiClass.data.id))
  362. {
  363. this.yotogi_class_unit_dic_[this.maid_.status.selectedYotogiClass.data.id].UpdateInfo();
  364. }
  365. }
  366. public static Dictionary<int, SortedList<int, List<Skill.Data>>> job_class_special_skill_list
  367. {
  368. get
  369. {
  370. return ClassChangePanel.job_class_special_skill_list_;
  371. }
  372. }
  373. private static Dictionary<int, SortedList<int, List<Skill.Data>>> job_class_special_skill_list_ = new Dictionary<int, SortedList<int, List<Skill.Data>>>();
  374. private Maid maid_;
  375. private UIWFTabPanel class_type_tab_panel_;
  376. private UIWFTabButton job_class_button_;
  377. private ClassChangePanel.UISet yotogiUIs;
  378. private ClassChangePanel.UISet jobUIs;
  379. private Dictionary<int, ClassUnit> job_class_unit_dic_ = new Dictionary<int, ClassUnit>();
  380. private Dictionary<int, ClassUnit> yotogi_class_unit_dic_ = new Dictionary<int, ClassUnit>();
  381. private ClassChangePanel.InfoPanelItem info_panel_item_ = default(ClassChangePanel.InfoPanelItem);
  382. private struct InfoPanelItem
  383. {
  384. public UILabel class_name;
  385. public UILabel class_level;
  386. public UILabel current_exp;
  387. public UILabel next_exp;
  388. public UILabel info_text;
  389. public List<UILabel> special_skill;
  390. }
  391. private class UISet
  392. {
  393. public void Reset()
  394. {
  395. if (this.itemGrid != null)
  396. {
  397. Utility.ResetNGUI(this.itemGrid);
  398. }
  399. if (this.scrollView)
  400. {
  401. Utility.ResetNGUI(this.scrollView);
  402. }
  403. }
  404. public GameObject classListObject;
  405. public UIWFTabButton selectButton;
  406. public UIGrid itemGrid;
  407. public UIWFTabPanel tabPanel;
  408. public UIScrollView scrollView;
  409. }
  410. }