PartnerPartnerListItemCtrl.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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.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 PartnerPartnerListItemCtrl : UIController<PartnerPartnerListItemVM>
  17. {
  18. private int _lineupPlanIndex;
  19. private long _partnerId;
  20. protected override void OnEnable(object intent)
  21. {
  22. AddUIListenres();
  23. }
  24. protected override void OnDisable()
  25. {
  26. RemoveUIListenres();
  27. }
  28. #region UI事件
  29. private void AddUIListenres()
  30. {
  31. VM.ClickBtn.onClick.Add(OnClickBtn);
  32. }
  33. private void RemoveUIListenres()
  34. {
  35. VM.ClickBtn.onClick.Remove(OnClickBtn);
  36. }
  37. private void OnClickBtn(EventContext context)
  38. {
  39. EventSingle.Instance.Notify(EventDefine.ShowTips, "显示圣兵替换界面");
  40. Context.UI.OpenAsync(UIKeys.PartnerReplacePartnerPanel, new PartnerParam()
  41. {
  42. partnerId = _partnerId,
  43. lineupPlanIndex = _lineupPlanIndex
  44. });
  45. }
  46. #endregion
  47. public void OnRefresh(int index, PartnerParam param)
  48. {
  49. _partnerId = param.partnerId;
  50. _lineupPlanIndex = param.lineupPlanIndex;
  51. VM.StateCtrl.selectedIndex = _partnerId > 0 ? 1 : 0;
  52. if (_partnerId > 0)
  53. {
  54. PartnerAttributes partnerData = PartnersData.Instance.PartnersMap[_partnerId];
  55. if (partnerData != null)
  56. {
  57. VM.PartnerItem.Ctrl.ShowUI(partnerData.TableId);
  58. }
  59. }
  60. }
  61. }
  62. }