PartnerEpiBagListItemCtrl.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. }
  46. );
  47. }
  48. #endregion
  49. #region 属性
  50. private int _id;
  51. #endregion
  52. public void OnRefresh(int index, EpigraphTable table)
  53. {
  54. _id = table.Id;
  55. VM.EpiIcon.Ctrl.SetEpiIcon(_id, true);
  56. var info = EpigraphData.Instance.GetEpigraphAttrByTableId(_id);
  57. if (info != null)
  58. {
  59. if (info.PartnerId > 0)
  60. {
  61. var partnerTable = PartnerTableRepo.Get(info.PartnerId);
  62. if(partnerTable == null)
  63. {
  64. Log.Error($"圣兵表不存在,${info.PartnerId}");
  65. return;
  66. }
  67. VM.IsBind.selectedIndex = 0;
  68. VM.PzLoader.url = AddressableDefine.EpigraphTypePz(table.Quality);
  69. VM.IconLoader.url = partnerTable?.Icon2;
  70. }
  71. else
  72. {
  73. VM.IsBind.selectedIndex = 1;
  74. }
  75. }
  76. else
  77. {
  78. VM.IsBind.selectedIndex = 1;
  79. }
  80. OnUpdateProgress();
  81. }
  82. private void OnUpdateProgress()
  83. {
  84. var info = EpigraphData.Instance.GetEpigraphAttrByTableId(_id);
  85. var curlv = info != null ? info.StarLv : 1;
  86. var table = epigraphUpTableRepo.GetEpiragphUp(_id, curlv);
  87. if (table == null)
  88. {
  89. Log.Error($"铭文升级表不存在,id:{_id}, lv:{curlv}");
  90. return;
  91. }
  92. VM.ChipPbar.max = table.LevelUpCost;
  93. VM.ChipPbar.value = ItemData.Instance.GetItemNum(table.PetId);
  94. }
  95. }
  96. }