using System; using System.Collections.Generic; using MaidStatus; using MaidStatus.CsvData; using UnityEngine; using wf; using Yotogis; public class ClassChangePanel : MonoBehaviour { public static void CreateClassText() { if (ClassChangePanel.job_class_special_skill_list_.Count != 0) { return; } foreach (JobClass.Data data in JobClass.GetAllDatas(false)) { ClassChangePanel.job_class_special_skill_list_.Add(data.id, new SortedList>()); } } public void Awake() { if (this.job_class_unit_dic_.Count != 0) { return; } this.class_type_tab_panel_ = UTY.GetChildObject(base.gameObject, "ClassViewer/TabButton", false).GetComponent(); this.job_class_button_ = UTY.GetChildObject(base.gameObject, "ClassViewer/TabButton/MaidClass", false).GetComponent(); this.info_panel_item_.class_name = UTY.GetChildObject(base.gameObject, "ClassViewer/Common/ClassDescription/ClassName", false).GetComponent(); this.info_panel_item_.class_level = UTY.GetChildObject(base.gameObject, "ClassViewer/Common/ClassDescription/LevelGroup/Level/Value", false).GetComponent(); this.info_panel_item_.current_exp = UTY.GetChildObject(base.gameObject, "ClassViewer/Common/ClassDescription/LevelGroup/Exp/Value", false).GetComponent(); this.info_panel_item_.next_exp = UTY.GetChildObject(base.gameObject, "ClassViewer/Common/ClassDescription/LevelGroup/RequiredExp/Value", false).GetComponent(); this.info_panel_item_.info_text = UTY.GetChildObject(base.gameObject, "ClassViewer/Common/ClassDescription/Description", false).GetComponent(); this.info_panel_item_.special_skill = new List(); GameObject childObject = UTY.GetChildObject(base.gameObject, "ClassViewer/Yotogi/SkillList/Contents/UnitParent", false); int childCount = childObject.transform.childCount; for (int i = 0; i < childCount; i++) { this.info_panel_item_.special_skill.Add(childObject.transform.GetChild(i).gameObject.GetComponent()); } this.jobUIs = new ClassChangePanel.UISet(); this.jobUIs.selectButton = UTY.GetChildObject(this.class_type_tab_panel_.gameObject, "MaidClass", false).GetComponent(); this.jobUIs.classListObject = UTY.GetChildObject(base.gameObject, "ClassViewer/Common/ClassListMaid", false); this.jobUIs.itemGrid = UTY.GetChildObject(this.jobUIs.classListObject, "Contents/UnitParent", false).GetComponent(); this.jobUIs.scrollView = UTY.GetChildObject(this.jobUIs.classListObject, "Contents", false).GetComponent(); this.jobUIs.tabPanel = this.jobUIs.classListObject.GetComponentInChildren(); this.jobUIs.classListObject.SetActive(true); List allDatas = JobClass.GetAllDatas(true); allDatas.Sort(); foreach (JobClass.Data data in allDatas) { ClassUnit component = Utility.CreatePrefab(this.jobUIs.itemGrid.gameObject, "SceneCompetitiveShow/Prefab/ClassUnit", true).GetComponent(); component.SetJobClassType(data.id); component.SetClassChangePanel(this); component.SetOnSelectEvent(new Action(this.OnSelectClassUnitEvent)); UIEventTrigger[] componentsInChildren = component.GetComponentsInChildren(); EventDelegate eventDelegate = new EventDelegate(this, "OnUnitMouseHoverIn"); eventDelegate.parameters[0].value = component; foreach (UIEventTrigger uieventTrigger in componentsInChildren) { EventDelegate.Add(uieventTrigger.onHoverOver, eventDelegate); EventDelegate.Add(uieventTrigger.onHoverOut, new EventDelegate.Callback(this.OnUnitMouseHoverOut)); } this.job_class_unit_dic_.Add(data.id, component); } this.jobUIs.tabPanel.UpdateChildren(); this.jobUIs.itemGrid.repositionNow = true; EventDelegate.Add(this.jobUIs.selectButton.onSelect, new EventDelegate.Callback(this.OnSelectType)); this.jobUIs.classListObject.SetActive(false); this.yotogiUIs = new ClassChangePanel.UISet(); this.yotogiUIs.selectButton = UTY.GetChildObject(this.class_type_tab_panel_.gameObject, "YotogiClass", false).GetComponent(); this.yotogiUIs.classListObject = UTY.GetChildObject(base.gameObject, "ClassViewer/Common/ClassListYotogi", false); this.yotogiUIs.itemGrid = UTY.GetChildObject(this.yotogiUIs.classListObject, "Contents/UnitParent", false).GetComponent(); this.yotogiUIs.scrollView = UTY.GetChildObject(this.yotogiUIs.classListObject, "Contents", false).GetComponent(); this.yotogiUIs.tabPanel = this.yotogiUIs.classListObject.GetComponentInChildren(); this.yotogiUIs.classListObject.SetActive(true); foreach (YotogiClass.Data data2 in YotogiClass.GetAllDatas(true)) { ClassUnit component2 = Utility.CreatePrefab(this.yotogiUIs.itemGrid.gameObject, "SceneCompetitiveShow/Prefab/ClassUnit", true).GetComponent(); component2.SetYotogiClassType(data2.id); component2.SetClassChangePanel(this); component2.SetOnSelectEvent(new Action(this.OnSelectClassUnitEvent)); UIEventTrigger[] componentsInChildren2 = component2.GetComponentsInChildren(); EventDelegate eventDelegate2 = new EventDelegate(this, "OnUnitMouseHoverIn"); eventDelegate2.parameters[0].value = component2; foreach (UIEventTrigger uieventTrigger2 in componentsInChildren2) { EventDelegate.Add(uieventTrigger2.onHoverOver, eventDelegate2); EventDelegate.Add(uieventTrigger2.onHoverOut, new EventDelegate.Callback(this.OnUnitMouseHoverOut)); } this.yotogi_class_unit_dic_.Add(data2.id, component2); } this.yotogiUIs.tabPanel.UpdateChildren(); this.yotogiUIs.itemGrid.repositionNow = true; EventDelegate.Add(this.yotogiUIs.selectButton.onSelect, new EventDelegate.Callback(this.OnSelectType)); this.yotogiUIs.classListObject.SetActive(false); ClassChangePanel.CreateClassText(); this.class_type_tab_panel_.gameObject.SetActive(false); } public void OnEnable() { this.jobUIs.Reset(); this.yotogiUIs.Reset(); } public void SetTargetMaid(Maid maid) { if (this.job_class_unit_dic_.Count == 0) { bool activeSelf = base.gameObject.activeSelf; base.gameObject.SetActive(true); this.Awake(); base.gameObject.SetActive(activeSelf); } this.maid_ = maid; Status status = this.maid_.status; foreach (KeyValuePair keyValuePair in this.job_class_unit_dic_) { keyValuePair.Value.UpdateMaidData(this.maid_); } this.jobUIs.tabPanel.ResetSelect(); foreach (KeyValuePair keyValuePair2 in this.job_class_unit_dic_) { ClassUnit value = keyValuePair2.Value; value.button.SetSelect(false); value.button.isEnabled = status.jobClass.Contains(value.maid_class_type); JobClass.Data data = JobClass.GetData(value.maid_class_type); if (MaidManagement.compatibilityMode) { value.gameObject.SetActive(data.classType != AbstractClassData.ClassType.New); } else { value.gameObject.SetActive(data.classType != AbstractClassData.ClassType.Old); } if (value.gameObject.activeSelf) { value.gameObject.SetActive(data.learnConditions.isLearnPossiblePersonal(maid.status.personal)); } } GameObject gameObject = this.yotogiUIs.itemGrid.gameObject; while (gameObject.transform.parent != null && !gameObject.transform.gameObject.activeInHierarchy) { gameObject = ((!(gameObject.transform.parent != null)) ? null : gameObject.transform.parent.gameObject); } if (gameObject != null) { gameObject.SetActive(true); } this.jobUIs.Reset(); int num = (status.selectedJobClass == null) ? int.MinValue : status.selectedJobClass.data.id; if (num != -2147483648) { this.jobUIs.tabPanel.Select(this.job_class_unit_dic_[num].button); if (this.jobUIs.classListObject.activeSelf) { this.job_class_unit_dic_[num].UpdateInfo(); } } foreach (KeyValuePair keyValuePair3 in this.yotogi_class_unit_dic_) { keyValuePair3.Value.UpdateMaidData(this.maid_); } this.yotogiUIs.tabPanel.ResetSelect(); foreach (KeyValuePair keyValuePair4 in this.yotogi_class_unit_dic_) { ClassUnit value2 = keyValuePair4.Value; value2.button.SetSelect(false); value2.button.isEnabled = status.yotogiClass.Contains(value2.yotogi_class_type); YotogiClass.Data data2 = YotogiClass.GetData(value2.yotogi_class_type); value2.gameObject.SetActive(data2.learnConditions.isLearnPossiblePersonal(maid.status.personal)); } gameObject = this.yotogiUIs.itemGrid.gameObject; while (gameObject.transform.parent != null && !gameObject.transform.gameObject.activeInHierarchy) { gameObject = ((!(gameObject.transform.parent != null)) ? null : gameObject.transform.parent.gameObject); } if (gameObject != null) { gameObject.SetActive(true); } this.yotogiUIs.Reset(); num = ((status.selectedYotogiClass == null) ? int.MinValue : status.selectedYotogiClass.data.id); if (num != -2147483648) { this.yotogiUIs.tabPanel.Select(this.yotogi_class_unit_dic_[num].button); if (this.yotogiUIs.classListObject.activeSelf) { this.yotogi_class_unit_dic_[num].UpdateInfo(); } } if (this.class_type_tab_panel_.GetSelectButtonObject() == null) { this.class_type_tab_panel_.Select(this.job_class_button_); } } private void OnSelectType() { if (!UIWFSelectButton.current.isSelected) { return; } this.jobUIs.classListObject.SetActive(true); this.yotogiUIs.classListObject.SetActive(false); this.jobUIs.Reset(); if (this.maid_ != null && this.maid_.status.selectedJobClass != null) { this.job_class_unit_dic_[this.maid_.status.selectedJobClass.data.id].UpdateInfo(); } } public void SetInfoData(int maid_class_type) { if (this.maid_ == null) { return; } JobClass.Data data = JobClass.GetData(maid_class_type); ClassData classData = this.maid_.status.jobClass.Get(maid_class_type); this.info_panel_item_.class_name.text = data.drawName; Utility.SetLocalizeTerm(this.info_panel_item_.class_name, data.termName); this.info_panel_item_.info_text.text = data.explanatoryText; Utility.SetLocalizeTerm(this.info_panel_item_.info_text, data.termExplanatoryText); if (classData != null) { this.info_panel_item_.class_level.text = classData.level.ToString(); this.info_panel_item_.current_exp.text = classData.cur_exp.ToString(); this.info_panel_item_.next_exp.text = classData.next_exp.ToString(); } else { this.info_panel_item_.class_level.text = "-"; this.info_panel_item_.current_exp.text = "-"; this.info_panel_item_.next_exp.text = "-"; } string[] array = new string[this.info_panel_item_.special_skill.Count]; int num = 0; foreach (KeyValuePair> keyValuePair in ClassChangePanel.job_class_special_skill_list_[maid_class_type]) { foreach (Skill.Data data2 in keyValuePair.Value) { if (num < array.Length) { array[num++] = data2.name; if (array.Length == num) { array[num - 1] = "etc..."; } } if (array.Length == num) { break; } } if (array.Length == num) { break; } } for (int i = 0; i < array.Length; i++) { if (string.IsNullOrEmpty(array[i])) { this.info_panel_item_.special_skill[i].gameObject.SetActive(false); } else { this.info_panel_item_.special_skill[i].gameObject.SetActive(true); this.info_panel_item_.special_skill[i].text = array[i]; } } } public void SetInfoDataYotogi(int yotogi_class_type) { if (this.maid_ == null) { return; } YotogiClass.Data data = YotogiClass.GetData(yotogi_class_type); ClassData classData = this.maid_.status.yotogiClass.Get(yotogi_class_type); this.info_panel_item_.class_name.text = data.drawName; this.info_panel_item_.info_text.text = data.explanatoryText; if (classData != null) { this.info_panel_item_.class_level.text = classData.level.ToString(); this.info_panel_item_.current_exp.text = classData.cur_exp.ToString(); this.info_panel_item_.next_exp.text = classData.next_exp.ToString(); } else { this.info_panel_item_.class_level.text = "-"; this.info_panel_item_.current_exp.text = "-"; this.info_panel_item_.next_exp.text = "-"; } string[] array = new string[this.info_panel_item_.special_skill.Count]; int num = 0; foreach (KeyValuePair> keyValuePair in YotogiClass.GetLearnSkillList(yotogi_class_type)) { foreach (Skill.Data data2 in keyValuePair.Value) { if (num < array.Length) { array[num++] = data2.name; if (array.Length == num) { array[num - 1] = "etc..."; } } if (array.Length == num) { break; } } if (array.Length == num) { break; } } for (int i = 0; i < array.Length; i++) { if (string.IsNullOrEmpty(array[i])) { this.info_panel_item_.special_skill[i].gameObject.SetActive(false); } else { this.info_panel_item_.special_skill[i].gameObject.SetActive(true); this.info_panel_item_.special_skill[i].text = array[i]; } } } private void OnSelectClassUnitEvent(ClassUnit unit) { if (this.maid_ == null) { return; } if (unit.maid_class_type != -2147483648) { if (this.maid_.status.selectedJobClass.data.id != unit.maid_class_type) { this.maid_.status.ChangeJobClass(unit.maid_class_type); } } else if (unit.yotogi_class_type != -2147483648 && this.maid_.status.selectedYotogiClass.data.id != unit.yotogi_class_type) { this.maid_.status.ChangeYotogiClass(unit.yotogi_class_type); } } private void OnUnitMouseHoverIn(ClassUnit class_unit) { class_unit.UpdateInfo(); } private void OnUnitMouseHoverOut() { if (this.jobUIs.classListObject.activeSelf) { if (this.maid_ != null && this.maid_.status.selectedJobClass != null && this.job_class_unit_dic_.ContainsKey(this.maid_.status.selectedJobClass.data.id)) { this.job_class_unit_dic_[this.maid_.status.selectedJobClass.data.id].UpdateInfo(); } } else if (this.maid_ != null && this.maid_.status.selectedYotogiClass != null && this.yotogi_class_unit_dic_.ContainsKey(this.maid_.status.selectedYotogiClass.data.id)) { this.yotogi_class_unit_dic_[this.maid_.status.selectedYotogiClass.data.id].UpdateInfo(); } } public static Dictionary>> job_class_special_skill_list { get { return ClassChangePanel.job_class_special_skill_list_; } } private static Dictionary>> job_class_special_skill_list_ = new Dictionary>>(); private Maid maid_; private UIWFTabPanel class_type_tab_panel_; private UIWFTabButton job_class_button_; private ClassChangePanel.UISet yotogiUIs; private ClassChangePanel.UISet jobUIs; private Dictionary job_class_unit_dic_ = new Dictionary(); private Dictionary yotogi_class_unit_dic_ = new Dictionary(); private ClassChangePanel.InfoPanelItem info_panel_item_ = default(ClassChangePanel.InfoPanelItem); private struct InfoPanelItem { public UILabel class_name; public UILabel class_level; public UILabel current_exp; public UILabel next_exp; public UILabel info_text; public List special_skill; } private class UISet { public void Reset() { if (this.itemGrid != null) { Utility.ResetNGUI(this.itemGrid); } if (this.scrollView) { Utility.ResetNGUI(this.scrollView); } } public GameObject classListObject; public UIWFTabButton selectButton; public UIGrid itemGrid; public UIWFTabPanel tabPanel; public UIScrollView scrollView; } }