PlayerTransferSucessPanelCtrl.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using FairyGUI;
  7. using FL.Data;
  8. using XGame.Database;
  9. using XGame.Framework.UI;
  10. namespace FL.FGUI
  11. {
  12. /// <summary>
  13. /// UI逻辑处理类
  14. /// </summary>
  15. /// <typeparam name=""></typeparam>
  16. public partial class PlayerTransferSucessPanelCtrl : UIController<PlayerTransferSucessPanelVM>
  17. {
  18. protected override void OnEnable(object intent)
  19. {
  20. AddUIListenres();
  21. ShowUI();
  22. }
  23. protected override void OnDisable()
  24. {
  25. RemoveUIListenres();
  26. VM.JobSpine.url = string.Empty;
  27. }
  28. #region UI事件
  29. private void AddUIListenres()
  30. {
  31. VM.BackBtn.onClick.Add(OnClickBackBtn);
  32. VM.ActiveSkillBtn.onClick.Add(OnClickActiveSkillBtn);
  33. VM.PassiveSkillBtn.onClick.Add(OnClickPassiveSkillBtn);
  34. }
  35. private void RemoveUIListenres()
  36. {
  37. VM.BackBtn.onClick.Remove(OnClickBackBtn);
  38. VM.ActiveSkillBtn.onClick.Remove(OnClickActiveSkillBtn);
  39. VM.PassiveSkillBtn.onClick.Remove(OnClickPassiveSkillBtn);
  40. }
  41. /// <summary>
  42. /// 点击主动技能
  43. /// </summary>
  44. /// <param name="context"></param>
  45. private void OnClickActiveSkillBtn(EventContext context)
  46. {
  47. OpenPlayerJobInformationPanel();
  48. }
  49. /// <summary>
  50. /// 点击被动技能
  51. /// </summary>
  52. /// <param name="context"></param>
  53. private void OnClickPassiveSkillBtn(EventContext context)
  54. {
  55. OpenPlayerJobInformationPanel();
  56. }
  57. private void OnClickBackBtn(EventContext context)
  58. {
  59. Context.ClosePanel();
  60. }
  61. #endregion
  62. private void ShowUI()
  63. {
  64. var jobInfo = careerTableRepo.Get(PlayerData.Instance.JobId);
  65. if (jobInfo == null) return;
  66. VM.JobName.text = jobInfo.Name;
  67. ShowSkill(jobInfo.Skill);
  68. ShowPassiveSkill(jobInfo.Passive_skill);
  69. LoadJobSpine("info_job_1001_1_SkeletonData");
  70. }
  71. /// <summary>
  72. /// 主动技能
  73. /// </summary>
  74. /// <param name="skillIds"></param>
  75. private void ShowSkill(int[] skillIds)
  76. {
  77. bool bShow = skillIds != null && skillIds.Length > 0;
  78. if (bShow) {
  79. VM.AdvanceSkillItem.Enable(null);
  80. }
  81. else
  82. {
  83. VM.AdvanceSkillItem.Disable();
  84. }
  85. if (bShow)
  86. VM.AdvanceSkillItem.Ctrl.ShowUI(skillIds[1]);
  87. }
  88. /// <summary>
  89. /// 被动技能
  90. /// </summary>
  91. /// <param name="skillIds"></param>
  92. private void ShowPassiveSkill(int[] skillIds)
  93. {
  94. bool bShow = skillIds != null && skillIds.Length > 0;
  95. if (bShow) {
  96. VM.AdvancePassiveSkillItem.Enable(null);
  97. } else
  98. {
  99. VM.AdvancePassiveSkillItem.Disable();
  100. }
  101. if (bShow)
  102. VM.AdvancePassiveSkillItem.Ctrl.ShowUI(skillIds[1]);
  103. }
  104. /// <summary>
  105. /// 加载主角的spine
  106. /// </summary>
  107. /// <param name="spineName"></param>
  108. private void LoadJobSpine(string spineName)
  109. {
  110. VM.JobSpine.LoadSpine(spineName, "stand", true);
  111. }
  112. /// <summary>
  113. /// 打开职业详情界面
  114. /// </summary>
  115. private void OpenPlayerJobInformationPanel()
  116. {
  117. Context.UI.OpenAsync(UIKeys.PlayerJobInformationPanel);
  118. }
  119. }
  120. }