PlayerJobInfoSkillNestedCtrl.cs 5.1 KB

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