PartnerEpiBagListItemCtrl.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. VM.IsBind.selectedIndex = 0;
  66. VM.PzLoader.url = AddressableDefine.EpigraphTypePz(table.Quality);
  67. VM.IconLoader.url = partnerTable?.Icon;
  68. }
  69. else
  70. {
  71. VM.IsBind.selectedIndex = 1;
  72. }
  73. }
  74. else
  75. {
  76. VM.IsBind.selectedIndex = 1;
  77. }
  78. OnUpdateProgress();
  79. }
  80. private void OnUpdateProgress()
  81. {
  82. var info = EpigraphData.Instance.GetEpigraphAttrByTableId(_id);
  83. var curlv = info != null ? info.StarLv : 1;
  84. var table = epigraphUpTableRepo.GetEpiragphUp(_id, curlv);
  85. if (table == null)
  86. {
  87. Log.Error($"铭文升级表不存在,id:{_id}, lv:{curlv}");
  88. return;
  89. }
  90. VM.ChipPbar.max = table.LevelUpCost;
  91. VM.ChipPbar.value = ItemData.Instance.GetItemNum(table.PetId);
  92. }
  93. }
  94. }