PlayerTransferListItemCtrl.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 UnityEngine;
  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 PlayerTransferListItemCtrl : UIController<PlayerTransferListItemVM>
  18. {
  19. private int _skillId; // 主动技能id
  20. private int _passiveSkillId; // 被动技能id
  21. protected override void OnEnable(object intent)
  22. {
  23. AddUIListenres();
  24. }
  25. protected override void OnDisable()
  26. {
  27. RemoveUIListenres();
  28. VM.JobSpine.url = string.Empty;
  29. }
  30. #region UI事件
  31. private void AddUIListenres()
  32. {
  33. VM.SkillBtn.onClick.Add(OnClickSkillBtn);
  34. VM.PassiveSkillBtn.onClick.Add(OnClickPassiveSkillBtn);
  35. }
  36. private void RemoveUIListenres()
  37. {
  38. VM.SkillBtn.onClick.Remove(OnClickSkillBtn);
  39. VM.PassiveSkillBtn.onClick.Remove(OnClickPassiveSkillBtn);
  40. }
  41. private void OnClickSkillBtn(EventContext context)
  42. {
  43. }
  44. private void OnClickPassiveSkillBtn(EventContext context)
  45. {
  46. }
  47. #endregion
  48. public void OnRefresh(int index, int jobId)
  49. {
  50. var jobInfo = careerTableRepo.Get(jobId);
  51. if (jobInfo == null) return;
  52. //VM.Tr.localScale.Set(1,1,1);
  53. VM.Scale = Vector3.one;
  54. VM.JobNameLabel.text = jobInfo.Name;
  55. VM.PositioningLabel.text = jobInfo.Job_pos;
  56. ShowJobSkillUI(jobInfo.Skill);
  57. ShowJobPassiveSkillUI(jobInfo.Passive_skill);
  58. LoadJobSpine("info_job_1001_1_SkeletonData");
  59. }
  60. /// <summary>
  61. /// 职业主动技能UI(解锁等级|技能id|技能等级)
  62. /// </summary>
  63. private void ShowJobSkillUI(int[] skillIds)
  64. {
  65. if (skillIds.Length > 1)
  66. {
  67. _skillId = skillIds[1];
  68. var skillInfo = SkillTableRepo.Get(skillIds[1]);
  69. if (skillInfo != null)
  70. {
  71. VM.SkillBtn.icon = skillInfo.Icon;
  72. }
  73. }
  74. else
  75. {
  76. _skillId = 0;
  77. }
  78. }
  79. /// <summary>
  80. /// 职业被动技能UI
  81. /// </summary>
  82. private void ShowJobPassiveSkillUI(int[] skillIds)
  83. {
  84. if (skillIds.Length > 1)
  85. {
  86. _passiveSkillId = skillIds[1];
  87. var skillInfo = SkillTableRepo.Get(skillIds[1]);
  88. if (skillInfo != null)
  89. {
  90. VM.PassiveSkillBtn.icon = skillInfo.Icon;
  91. }
  92. }
  93. else
  94. {
  95. _passiveSkillId = 0;
  96. }
  97. }
  98. /// <summary>
  99. /// 加载职业的spine
  100. /// </summary>
  101. /// <param name="spineName"></param>
  102. private void LoadJobSpine(string spineName)
  103. {
  104. VM.JobSpine.LoadSpine(spineName, "stand", true);
  105. }
  106. }
  107. }