ClassChangePanel.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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. this.info_panel_item_.info_text.text = data.explanatoryText;
  220. if (classData != null)
  221. {
  222. this.info_panel_item_.class_level.text = classData.level.ToString();
  223. this.info_panel_item_.current_exp.text = classData.cur_exp.ToString();
  224. this.info_panel_item_.next_exp.text = classData.next_exp.ToString();
  225. }
  226. else
  227. {
  228. this.info_panel_item_.class_level.text = "-";
  229. this.info_panel_item_.current_exp.text = "-";
  230. this.info_panel_item_.next_exp.text = "-";
  231. }
  232. string[] array = new string[this.info_panel_item_.special_skill.Count];
  233. int num = 0;
  234. foreach (KeyValuePair<int, List<Skill.Data>> keyValuePair in ClassChangePanel.job_class_special_skill_list_[maid_class_type])
  235. {
  236. foreach (Skill.Data data2 in keyValuePair.Value)
  237. {
  238. if (num < array.Length)
  239. {
  240. array[num++] = data2.name;
  241. if (array.Length == num)
  242. {
  243. array[num - 1] = "etc...";
  244. }
  245. }
  246. if (array.Length == num)
  247. {
  248. break;
  249. }
  250. }
  251. if (array.Length == num)
  252. {
  253. break;
  254. }
  255. }
  256. for (int i = 0; i < array.Length; i++)
  257. {
  258. if (string.IsNullOrEmpty(array[i]))
  259. {
  260. this.info_panel_item_.special_skill[i].gameObject.SetActive(false);
  261. }
  262. else
  263. {
  264. this.info_panel_item_.special_skill[i].gameObject.SetActive(true);
  265. this.info_panel_item_.special_skill[i].text = array[i];
  266. }
  267. }
  268. }
  269. public void SetInfoDataYotogi(int yotogi_class_type)
  270. {
  271. if (this.maid_ == null)
  272. {
  273. return;
  274. }
  275. YotogiClass.Data data = YotogiClass.GetData(yotogi_class_type);
  276. ClassData<YotogiClass.Data> classData = this.maid_.status.yotogiClass.Get(yotogi_class_type);
  277. this.info_panel_item_.class_name.text = data.drawName;
  278. this.info_panel_item_.info_text.text = data.explanatoryText;
  279. if (classData != null)
  280. {
  281. this.info_panel_item_.class_level.text = classData.level.ToString();
  282. this.info_panel_item_.current_exp.text = classData.cur_exp.ToString();
  283. this.info_panel_item_.next_exp.text = classData.next_exp.ToString();
  284. }
  285. else
  286. {
  287. this.info_panel_item_.class_level.text = "-";
  288. this.info_panel_item_.current_exp.text = "-";
  289. this.info_panel_item_.next_exp.text = "-";
  290. }
  291. string[] array = new string[this.info_panel_item_.special_skill.Count];
  292. int num = 0;
  293. foreach (KeyValuePair<int, List<Skill.Data>> keyValuePair in YotogiClass.GetLearnSkillList(yotogi_class_type))
  294. {
  295. foreach (Skill.Data data2 in keyValuePair.Value)
  296. {
  297. if (num < array.Length)
  298. {
  299. array[num++] = data2.name;
  300. if (array.Length == num)
  301. {
  302. array[num - 1] = "etc...";
  303. }
  304. }
  305. if (array.Length == num)
  306. {
  307. break;
  308. }
  309. }
  310. if (array.Length == num)
  311. {
  312. break;
  313. }
  314. }
  315. for (int i = 0; i < array.Length; i++)
  316. {
  317. if (string.IsNullOrEmpty(array[i]))
  318. {
  319. this.info_panel_item_.special_skill[i].gameObject.SetActive(false);
  320. }
  321. else
  322. {
  323. this.info_panel_item_.special_skill[i].gameObject.SetActive(true);
  324. this.info_panel_item_.special_skill[i].text = array[i];
  325. }
  326. }
  327. }
  328. private void OnSelectClassUnitEvent(ClassUnit unit)
  329. {
  330. if (this.maid_ == null)
  331. {
  332. return;
  333. }
  334. if (unit.maid_class_type != -2147483648)
  335. {
  336. if (this.maid_.status.selectedJobClass.data.id != unit.maid_class_type)
  337. {
  338. this.maid_.status.ChangeJobClass(unit.maid_class_type);
  339. }
  340. }
  341. else if (unit.yotogi_class_type != -2147483648 && this.maid_.status.selectedYotogiClass.data.id != unit.yotogi_class_type)
  342. {
  343. this.maid_.status.ChangeYotogiClass(unit.yotogi_class_type);
  344. }
  345. }
  346. private void OnUnitMouseHoverIn(ClassUnit class_unit)
  347. {
  348. class_unit.UpdateInfo();
  349. }
  350. private void OnUnitMouseHoverOut()
  351. {
  352. if (this.jobUIs.classListObject.activeSelf)
  353. {
  354. if (this.maid_ != null && this.maid_.status.selectedJobClass != null && this.job_class_unit_dic_.ContainsKey(this.maid_.status.selectedJobClass.data.id))
  355. {
  356. this.job_class_unit_dic_[this.maid_.status.selectedJobClass.data.id].UpdateInfo();
  357. }
  358. }
  359. else if (this.maid_ != null && this.maid_.status.selectedYotogiClass != null && this.yotogi_class_unit_dic_.ContainsKey(this.maid_.status.selectedYotogiClass.data.id))
  360. {
  361. this.yotogi_class_unit_dic_[this.maid_.status.selectedYotogiClass.data.id].UpdateInfo();
  362. }
  363. }
  364. public static Dictionary<int, SortedList<int, List<Skill.Data>>> job_class_special_skill_list
  365. {
  366. get
  367. {
  368. return ClassChangePanel.job_class_special_skill_list_;
  369. }
  370. }
  371. private static Dictionary<int, SortedList<int, List<Skill.Data>>> job_class_special_skill_list_ = new Dictionary<int, SortedList<int, List<Skill.Data>>>();
  372. private Maid maid_;
  373. private UIWFTabPanel class_type_tab_panel_;
  374. private UIWFTabButton job_class_button_;
  375. private ClassChangePanel.UISet yotogiUIs;
  376. private ClassChangePanel.UISet jobUIs;
  377. private Dictionary<int, ClassUnit> job_class_unit_dic_ = new Dictionary<int, ClassUnit>();
  378. private Dictionary<int, ClassUnit> yotogi_class_unit_dic_ = new Dictionary<int, ClassUnit>();
  379. private ClassChangePanel.InfoPanelItem info_panel_item_ = default(ClassChangePanel.InfoPanelItem);
  380. private struct InfoPanelItem
  381. {
  382. public UILabel class_name;
  383. public UILabel class_level;
  384. public UILabel current_exp;
  385. public UILabel next_exp;
  386. public UILabel info_text;
  387. public List<UILabel> special_skill;
  388. }
  389. private class UISet
  390. {
  391. public void Reset()
  392. {
  393. if (this.itemGrid != null)
  394. {
  395. Utility.ResetNGUI(this.itemGrid);
  396. }
  397. if (this.scrollView)
  398. {
  399. Utility.ResetNGUI(this.scrollView);
  400. }
  401. }
  402. public GameObject classListObject;
  403. public UIWFTabButton selectButton;
  404. public UIGrid itemGrid;
  405. public UIWFTabPanel tabPanel;
  406. public UIScrollView scrollView;
  407. }
  408. }