PlayerJobInfoSkillNestedCtrl.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 System.Collections.Generic;
  9. using XGame.Database;
  10. using XGame.Framework.UI;
  11. namespace FL.FGUI
  12. {
  13. /// <summary>
  14. /// UI逻辑处理类
  15. /// </summary>
  16. /// <typeparam name=""></typeparam>
  17. public partial class PlayerJobInfoSkillNestedCtrl : UIController<PlayerJobInfoSkillNestedVM>
  18. {
  19. private bool _bHideSkillInfo; // 是否需要隐藏技能信息气泡
  20. private List<JobSkillParam> _passiveSkillDataArray;
  21. protected override void OnEnable(object intent)
  22. {
  23. AddUIListenres();
  24. }
  25. protected override void OnDisable()
  26. {
  27. RemoveUIListenres();
  28. VM.SkillInfoNested.Disable();
  29. _passiveSkillDataArray?.Clear();
  30. _passiveSkillDataArray = null;
  31. }
  32. #region UI事件
  33. private void AddUIListenres()
  34. {
  35. VM.BackBtn.onClick.Add(OnClickBackBtn);
  36. VM.PanelEvent.Add(OnCllickPanel);
  37. VM.PassiveSkillList.ItemClickEvent += OnClickPassiveSkillItem;
  38. }
  39. private void RemoveUIListenres()
  40. {
  41. VM.BackBtn.onClick.Remove(OnClickBackBtn);
  42. VM.PanelEvent.Remove(OnCllickPanel);
  43. VM.PassiveSkillList.ItemClickEvent -= OnClickPassiveSkillItem;
  44. }
  45. /// <summary>
  46. /// 隐藏技能信息气泡框
  47. /// </summary>
  48. /// <param name="context"></param>
  49. private void OnCllickPanel(EventContext context)
  50. {
  51. if (_bHideSkillInfo)
  52. {
  53. ShowSkillInfoGroup(false);
  54. }
  55. _bHideSkillInfo = true;
  56. }
  57. private void OnClickBackBtn(EventContext context)
  58. {
  59. Context.ClosePanel();
  60. }
  61. #endregion
  62. public void ShowUI(careerTable jobInfo)
  63. {
  64. _bHideSkillInfo = true;
  65. ShowSkillInfoGroup(false);
  66. if (jobInfo == null) jobInfo = careerTableRepo.Get(PlayerData.Instance.JobId);
  67. if (jobInfo == null) return;
  68. VM.JobNameLabel.text = jobInfo.Name;
  69. VM.JobTypeLabel.text = jobInfo.Job_pos;
  70. VM.JobDescLabel.text = jobInfo.Desc;
  71. ShowSkill(jobInfo.Skill);
  72. ShowJobPassiveSkillUI(jobInfo.Passive_skill);
  73. LoadJobSpine("info_job_1001_1_SkeletonData");
  74. }
  75. /// <summary>
  76. /// 主动技能
  77. /// </summary>
  78. /// <param name="skillIds"></param>
  79. private void ShowSkill(int[] skillIds)
  80. {
  81. var skillInfo = SkillTableRepo.Get(skillIds[1]);
  82. if (skillInfo == null) return;
  83. VM.SkillNameLabel.text = skillInfo.Name;
  84. VM.SkillDescLabel.text = skillInfo.Desc;
  85. VM.ActiveSkillIcon.icon = skillInfo.Icon;
  86. VM.SkillCdLabel.text = (skillInfo.RestTime * 0.001f).ToString("F1");
  87. }
  88. /// <summary>
  89. /// 职业被动技能UI
  90. /// </summary>
  91. private void ShowJobPassiveSkillUI(int[] skillIds)
  92. {
  93. int index = 0;
  94. if (_passiveSkillDataArray == null) _passiveSkillDataArray = new List<JobSkillParam>();
  95. for (int i = 0; i < skillIds.Length; i += 2)
  96. {
  97. _passiveSkillDataArray.Add(new JobSkillParam()
  98. {
  99. unlockLv = skillIds[i],
  100. skillId = skillIds[i + 1],
  101. });
  102. index++;
  103. }
  104. VM.PassiveSkillList.BindDatas(_passiveSkillDataArray);
  105. }
  106. /// <summary>
  107. /// 点击的被动技能项
  108. /// </summary>
  109. /// <param name="index"></param>
  110. private void OnClickPassiveSkillItem(int index)
  111. {
  112. _bHideSkillInfo = false;
  113. ShowSkillInfoGroup(true, index, SkillTableRepo.Get(_passiveSkillDataArray[index].skillId));
  114. }
  115. /// <summary>
  116. /// 显示技能弹窗信息UI
  117. /// </summary>
  118. /// <param name="Show"></param>
  119. /// <param name="bPassive"></param>
  120. private void ShowSkillInfoGroup(bool bShow, int index = 0, SkillTable skillInfo = null)
  121. {
  122. //Log.Debug($"ShowSkillInfoGroup bShow:{bShow} info:{skillInfo != null} Frame:{Time.frameCount}");
  123. if (bShow && skillInfo != null)
  124. {
  125. var skillParam = new SkillInfoParam()
  126. {
  127. bShowRightBubble = index > 1,
  128. skillInfo = skillInfo
  129. };
  130. if (VM.SkillInfoNested.Active)
  131. VM.SkillInfoNested.Ctrl.ShowSkillInfo(skillParam);
  132. else
  133. VM.SkillInfoNested.Enable(skillParam);
  134. VM.PosCtrl.selectedIndex = index;
  135. }
  136. else
  137. {
  138. VM.SkillInfoNested.Disable();
  139. }
  140. }
  141. /// <summary>
  142. /// 加载主角的spine
  143. /// </summary>
  144. /// <param name="spineName"></param>
  145. private void LoadJobSpine(string spineName)
  146. {
  147. VM.JobSpine.LoadSpine(spineName, "stand", true);
  148. }
  149. }
  150. }