ClassChangePanel.cs 16 KB

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