PartnerEpiBagListItemCtrl.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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.Database;
  10. using XGame.Framework.UI;
  11. namespace FL.FGUI
  12. {
  13. /// <summary>
  14. /// UI逻辑处理类
  15. /// </summary>
  16. /// <typeparam name=""></typeparam>
  17. public partial class PartnerEpiBagListItemCtrl : UIController<PartnerEpiBagListItemVM>
  18. {
  19. protected override void OnEnable(object intent)
  20. {
  21. AddUIListenres();
  22. }
  23. protected override void OnDisable()
  24. {
  25. RemoveUIListenres();
  26. }
  27. #region UI事件
  28. private void AddUIListenres()
  29. {
  30. VM.EpiIcon.VM.PanelEvent.Add(OnClickBagEpigraph);
  31. }
  32. private void RemoveUIListenres()
  33. {
  34. VM.EpiIcon.VM.PanelEvent.Remove(OnClickBagEpigraph);
  35. }
  36. #endregion
  37. #region 点击事件
  38. private void OnClickBagEpigraph(EventContext eventContext)
  39. {
  40. Context.UI.OpenAsync(
  41. UIKeys.PartnerEpiDetailInfo,
  42. new PartnerEpiDetailInfoParam()
  43. {
  44. EpigraphId = _id,
  45. PlanId = PartnersData.Instance.UsePlanId,
  46. SlotId = -1,
  47. PartnerId = 0
  48. }
  49. );
  50. }
  51. #endregion
  52. #region 属性
  53. private int _id;
  54. #endregion
  55. public void OnRefresh(int index, EpigraphTable table)
  56. {
  57. _id = table.Id;
  58. VM.EpiIcon.Ctrl.SetEpiIcon(_id, true);
  59. var info = EpigraphData.Instance.GetEpigraphAttrByTableId(_id);
  60. if (info != null)
  61. {
  62. if (info.PartnerId > 0)
  63. {
  64. var partnerTable = PartnerTableRepo.Get(info.PartnerId);
  65. if(partnerTable == null)
  66. {
  67. Log.Error($"圣兵表不存在,${info.PartnerId}");
  68. return;
  69. }
  70. VM.IsBind.selectedIndex = 0;
  71. VM.PzLoader.url = AddressableDefine.EpigraphTypePz(table.Quality);
  72. VM.IconLoader.url = partnerTable?.Icon2;
  73. }
  74. else
  75. {
  76. VM.IsBind.selectedIndex = 1;
  77. }
  78. }
  79. else
  80. {
  81. VM.IsBind.selectedIndex = 1;
  82. }
  83. OnUpdateProgress();
  84. }
  85. private void OnUpdateProgress()
  86. {
  87. var info = EpigraphData.Instance.GetEpigraphAttrByTableId(_id);
  88. var curlv = info != null ? info.StarLv : 1;
  89. var table = epigraphUpTableRepo.GetEpiragphUp(_id, curlv);
  90. if (table == null)
  91. {
  92. Log.Error($"铭文升级表不存在,id:{_id}, lv:{curlv}");
  93. return;
  94. }
  95. VM.ChipPbar.max = table.LevelUpCost;
  96. VM.ChipPbar.value = ItemData.Instance.GetItemNum(table.PetId);
  97. }
  98. }
  99. }