PartnerEpiUpListItemCtrl.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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;
  9. using XGame.Framework.UI;
  10. namespace FL.FGUI
  11. {
  12. /// <summary>
  13. /// UI逻辑处理类
  14. /// </summary>
  15. /// <typeparam name=""></typeparam>
  16. public partial class PartnerEpiUpListItemCtrl : UIController<PartnerEpiUpListItemVM>
  17. {
  18. protected override void OnEnable(object intent)
  19. {
  20. AddUIListenres();
  21. }
  22. protected override void OnDisable()
  23. {
  24. RemoveUIListenres();
  25. }
  26. #region UI事件
  27. private void AddUIListenres()
  28. {
  29. VM.PartnerItem.VM.PartnerBase.VM.ClickBtn.onClick.Add(OnClickClickBtn);
  30. VM.DownBtn.onClick.Add(OnClickDownBtn);
  31. VM.UpBtn.onClick.Add(OnClickUpBtn);
  32. VM.PartnerItem.VM.EpiSetBase.VM.ClickBtn.onClick.Add(OnClickEpiSet);
  33. }
  34. private void RemoveUIListenres()
  35. {
  36. VM.PartnerItem.VM.PartnerBase.VM.ClickBtn.onClick.Remove(OnClickClickBtn);
  37. VM.DownBtn.onClick.Remove(OnClickDownBtn);
  38. VM.UpBtn.onClick.Remove(OnClickUpBtn);
  39. VM.PartnerItem.VM.EpiSetBase.VM.ClickBtn.onClick.Remove(OnClickEpiSet);
  40. }
  41. private void OnClickEpiSet(EventContext eventContext)
  42. {
  43. if (EpigraphData.Instance.UpModeSelect > 0)
  44. {
  45. EventSingle.Instance.Notify(EventDefine.EpigraphUpModeSelect, _sbId);
  46. }
  47. else
  48. {
  49. var partnerInfo = PartnersData.Instance.GetPartnerAttrByTableId(_sbId);
  50. if (partnerInfo == null)
  51. {
  52. Log.Error($"圣兵数据不存在,id:{_sbId}");
  53. return;
  54. }
  55. Context.UI.OpenAsync(
  56. UIKeys.PartnerEpiChangePanel,
  57. new PartnerEpiChangePanelCtrlParam()
  58. {
  59. PlanId = PartnersData.Instance.UsePlanId,
  60. SlotId = -1,
  61. SbId = _sbId,
  62. }
  63. );
  64. }
  65. }
  66. private void OnClickClickBtn(EventContext context)
  67. {
  68. if (EpigraphData.Instance.UpModeSelect > 0)
  69. {
  70. EventSingle.Instance.Notify(EventDefine.EpigraphUpModeSelect, _sbId);
  71. }
  72. else if (_sbId > 0)
  73. {
  74. Context.UI.OpenAsync(UIKeys.PartnerDetailsPanel, _sbId);
  75. }
  76. }
  77. private void OnClickDownBtn(EventContext context)
  78. {
  79. var slotData = PartnersData.Instance.CurUsePlan.GetSlot(_pos);
  80. if (slotData.SbId <= 0)
  81. return;
  82. PartnersService.Instance.RequestPartnerDown(slotData.SbId);
  83. }
  84. private void OnClickUpBtn(EventContext context) { }
  85. #endregion
  86. #region 属性
  87. private int _pos;
  88. private int _sbId;
  89. #endregion
  90. public void OnRefresh(int index, int pos)
  91. {
  92. _pos = pos;
  93. var slotData = PartnersData.Instance.CurUsePlan.GetSlot(pos);
  94. _sbId = slotData?.SbId ?? 0;
  95. VM.IsUp.selectedIndex = _sbId > 0 ? 0 : 1;
  96. VM.PartnerItem.Ctrl.ShowUI(_sbId);
  97. }
  98. }
  99. }