MainHomeBuffInfoNestedCtrl.cs 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using FairyGUI;
  7. using FL.Battle.Buffs;
  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 MainHomeBuffInfoNestedCtrl : UIController<MainHomeBuffInfoNestedVM>
  17. {
  18. protected override void OnEnable(object intent)
  19. {
  20. AddUIListenres();
  21. EventSingle.Instance.AddListener(EventDefine.GameMainMapPreviewBuff, OnSinglePreviewBuff);
  22. EventSingle.Instance.AddListener(EventDefine.GameMainMapPushPreviewBuffs, OnPreviewBuffs);
  23. }
  24. protected override void OnDisable()
  25. {
  26. RemoveUIListenres();
  27. EventSingle.Instance.RemoveListener(EventDefine.GameMainMapPreviewBuff, OnSinglePreviewBuff);
  28. EventSingle.Instance.RemoveListener(EventDefine.GameMainMapPushPreviewBuffs, OnPreviewBuffs);
  29. }
  30. #region UI事件
  31. private void AddUIListenres()
  32. {
  33. VM.BuffShowBtn.onClick.Add(OnClickBuffShowBtn);
  34. }
  35. private void RemoveUIListenres()
  36. {
  37. VM.BuffShowBtn.onClick.Remove(OnClickBuffShowBtn);
  38. }
  39. private void OnClickBuffShowBtn(EventContext context)
  40. {
  41. EventSingle.Instance.Notify(EventDefine.GameMainMapReqPreviewBuffs);
  42. }
  43. #endregion
  44. private void OnSinglePreviewBuff(int eventId, object args)
  45. {
  46. var dto = (BuffPreviewDto)args;
  47. var isShow = dto.buffTableId > 0;
  48. VM.ShowInfoCtrl.selectedIndex = isShow ? 1 : 0;
  49. if (isShow)
  50. {
  51. var buffTable = BuffTableRepo.Get(dto.buffTableId);
  52. VM.BuffIcon.url = buffTable.Icon;
  53. VM.BuffLayerPar.max = dto.layerLimit;
  54. VM.BuffLayerPar.value = dto.layer;
  55. string triggerName;
  56. EQualityLevel quality;
  57. if (dto.isSkill)
  58. {
  59. var skill = SkillTableRepo.Get(dto.skillId);
  60. if (skill.BuffTie.Length == 2)
  61. {
  62. var triBuff = BuffTableRepo.Get(skill.BuffTie[1]);
  63. triggerName = triBuff.Name;
  64. }
  65. else
  66. {
  67. triggerName = skill.Name;
  68. }
  69. quality = (EQualityLevel)skill.Quality;
  70. }
  71. else
  72. {
  73. var epigraph = EpigraphTableRepo.Get(dto.skillId);
  74. triggerName = epigraph.Name;
  75. quality = epigraph.Quality;
  76. }
  77. VM.TriggerNameLabel.text = string.Format(StringDefine.common_bracket, triggerName);
  78. VM.TriggerNameLabel.color = quality.ToEquipNameColor();
  79. VM.TipsLabel.text = dto.layer == dto.layerLimit ? StringDefine.buff_preview_tips_attack : StringDefine.buff_preview_tips_coming;
  80. }
  81. }
  82. private void OnPreviewBuffs(int eventId, object args)
  83. {
  84. Context.UI.OpenAsync(UIKeys.MainBuffPreviewPanel, args);
  85. }
  86. }
  87. }