PartnerEpiPlanListItemCtrl.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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.Framework.UI;
  9. namespace FL.FGUI
  10. {
  11. /// <summary>
  12. /// UI逻辑处理类
  13. /// </summary>
  14. /// <typeparam name=""></typeparam>
  15. public partial class PartnerEpiPlanListItemCtrl : UIController<PartnerEpiPlanListItemVM>
  16. {
  17. protected override void OnEnable(object intent)
  18. {
  19. AddUIListenres();
  20. }
  21. protected override void OnDisable()
  22. {
  23. RemoveUIListenres();
  24. }
  25. #region UI事件
  26. private void AddUIListenres()
  27. {
  28. VM.PartnerItem.VM.PartnerBase.VM.ClickBtn.onClick.Add(OnClickPartner);
  29. VM.PartnerItem.VM.EpiSetBase.VM.ClickBtn.onClick.Add(OnClickEpiSet);
  30. }
  31. private void RemoveUIListenres()
  32. {
  33. VM.PartnerItem.VM.PartnerBase.VM.ClickBtn.onClick.Remove(OnClickPartner);
  34. VM.PartnerItem.VM.EpiSetBase.VM.ClickBtn.onClick.Remove(OnClickEpiSet);
  35. }
  36. private void OnClickEpiSet(EventContext eventContext)
  37. {
  38. if (_sbId == 0)
  39. {
  40. Context.ShowTips(StringDefine.PartnerCurSlotNoSbTips);
  41. return;
  42. }
  43. Context.UI.OpenAsync(
  44. UIKeys.PartnerEpiChangePanel,
  45. new PartnerEpiChangePanelCtrlParam()
  46. {
  47. PlanId = _planId,
  48. SlotId = _slotId,
  49. SbId = _sbId,
  50. }
  51. );
  52. }
  53. private void OnClickPartner(EventContext eventContext)
  54. {
  55. Context.UI.OpenAsync(
  56. UIKeys.PartnerReplacePartnerPanel,
  57. new PartnerReplacePartnerPanelCtrlParam() { PlanId = _planId, SlotId = _slotId }
  58. );
  59. }
  60. #endregion
  61. #region 属性
  62. private int _planId;
  63. private int _slotId;
  64. private int _sbId;
  65. #endregion
  66. public void OnRefresh(int index, PartnerPlanParam param)
  67. {
  68. _planId = param.planId;
  69. _slotId = param.slotId;
  70. var slot = PartnersData.Instance.GetPlanSlot(_planId, _slotId);
  71. _sbId = slot?.SbId ?? 0;
  72. VM.IsEmpty.selectedIndex = _sbId > 0 ? 0 : 1;
  73. VM.PartnerItem.Ctrl.ShowUI(_sbId, _planId, _slotId);
  74. }
  75. }
  76. }