PartnerSbMainPanelCtrl.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /// #pkgName FGUI包名
  2. /// #panelName UIPanel名字
  3. /// #UIName = $"{#pkgName}{#panelName}" UIKey名字
  4. /// 该脚本由模板创建
  5. /// created by cb 2024
  6. using System.Collections.Generic;
  7. using FairyGUI;
  8. using FL.Data;
  9. using XGame;
  10. using XGame.Framework.UI;
  11. namespace FL.FGUI
  12. {
  13. /// <summary>
  14. /// UI逻辑处理类
  15. /// </summary>
  16. /// <typeparam name=""></typeparam>
  17. public partial class PartnerSbMainPanelCtrl : UIController<PartnerSbMainPanelVM>
  18. {
  19. protected override void OnEnable(object intent)
  20. {
  21. AddUIListenres();
  22. InitView();
  23. ShowUI();
  24. }
  25. protected override void OnDisable()
  26. {
  27. RemoveUIListenres();
  28. }
  29. #region UI事件
  30. private void AddUIListenres()
  31. {
  32. VM.ReplaceBtn.onClick.Add(OnClickReplaceBtn);
  33. VM.StrengthBtn.onClick.Add(OnClickStrengthBtn);
  34. VM.OneUpBtn.onClick.Add(OnClickOneUpBtn);
  35. VM.RecommendBtn.onClick.Add(OnClickRecommendBtn);
  36. VM.BagBtn.onClick.Add(OnClickBagBtn);
  37. VM.MaskBtn.onClick.Add(OnClickMaskBtn);
  38. VM.ConfirmBtn.onClick.Add(OnClickConfirmBtn);
  39. VM.CancelBtn.onClick.Add(OnClickCancelBtn);
  40. }
  41. private void RemoveUIListenres()
  42. {
  43. VM.ReplaceBtn.onClick.Remove(OnClickReplaceBtn);
  44. VM.StrengthBtn.onClick.Remove(OnClickStrengthBtn);
  45. VM.OneUpBtn.onClick.Remove(OnClickOneUpBtn);
  46. VM.RecommendBtn.onClick.Remove(OnClickRecommendBtn);
  47. VM.BagBtn.onClick.Remove(OnClickBagBtn);
  48. VM.MaskBtn.onClick.Remove(OnClickMaskBtn);
  49. VM.ConfirmBtn.onClick.Remove(OnClickConfirmBtn);
  50. VM.CancelBtn.onClick.Remove(OnClickCancelBtn);
  51. }
  52. private void OnClickReplaceBtn(EventContext context) { }
  53. private void OnClickStrengthBtn(EventContext context) { }
  54. private void OnClickOneUpBtn(EventContext context) { }
  55. private void OnClickRecommendBtn(EventContext context) { }
  56. private void OnClickBagBtn(EventContext context) { }
  57. private void OnClickMaskBtn(EventContext context) { }
  58. private void OnClickConfirmBtn(EventContext context) { }
  59. private void OnClickCancelBtn(EventContext context) { }
  60. #endregion
  61. #region 属性
  62. private bool _initView = false;
  63. private int _curSelectPos = 0;
  64. #endregion
  65. #region 页面
  66. private void InitView()
  67. {
  68. if (_initView)
  69. return;
  70. _initView = true;
  71. VM.SbList.ListType = EGListType.None;
  72. }
  73. private void ShowUI()
  74. {
  75. RefreshGoneUpPartners(true);
  76. UpdateDetail();
  77. }
  78. private void RefreshGoneUpPartners(bool chooseFirstSb)
  79. {
  80. var plan = PartnersData.Instance.CurUsePlan;
  81. if(plan == null)
  82. {
  83. Log.Error($"圣兵上阵方案不存在,id:{PartnersData.Instance.CurUsePlan}");
  84. return;
  85. }
  86. if (chooseFirstSb)
  87. {
  88. _curSelectPos = 0;
  89. for (int i = 0; i < PartnersData.GoneUpLimit; i++)
  90. {
  91. var slot = plan.GetSlot(i);
  92. if (slot?.SbId > 0)
  93. {
  94. _curSelectPos = i;
  95. break;
  96. }
  97. }
  98. }
  99. var list = new List<PartnerSbUpListItemParam>();
  100. for (int i = 0; i < PartnersData.GoneUpLimit; i++)
  101. {
  102. var data = new PartnerSbUpListItemParam()
  103. {
  104. PosId = i,
  105. CurSelectPos = _curSelectPos,
  106. };
  107. list.Add(data);
  108. }
  109. VM.SbList.BindDatas(list);
  110. }
  111. private void UpdateDetail()
  112. {
  113. var plan = PartnersData.Instance.CurUsePlan;
  114. if (plan == null)
  115. {
  116. Log.Error($"圣兵上阵方案不存在,id:{PartnersData.Instance.CurUsePlan}");
  117. return;
  118. }
  119. var slot = plan.GetSlot(_curSelectPos);
  120. VM.SbDetailNested.Ctrl.ShowUI(slot?.SbId ?? 0);
  121. }
  122. #endregion
  123. }
  124. }