PartnerEpiBagListItemCtrl.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 PartnerEpiBagListItemCtrl : UIController<PartnerEpiBagListItemVM>
  17. {
  18. protected override void OnEnable(object intent)
  19. {
  20. AddUIListenres();
  21. }
  22. protected override void OnDisable()
  23. {
  24. RemoveUIListenres();
  25. }
  26. #region UI事件
  27. private void AddUIListenres()
  28. {
  29. VM.Panel.onClick.Add(OnClickBagEpigraph);
  30. }
  31. private void RemoveUIListenres()
  32. {
  33. VM.Panel.onClick.Remove(OnClickBagEpigraph);
  34. }
  35. #endregion
  36. #region 点击事件
  37. private void OnClickBagEpigraph(EventContext eventContext)
  38. {
  39. Context.UI.OpenAsync(UIKeys.PartnerEpiDetailInfo, id);
  40. }
  41. #endregion
  42. #region 属性
  43. private int id;
  44. #endregion
  45. public void OnRefresh(int index, EpigraphTable table)
  46. {
  47. id = table.Id;
  48. VM.EpiIcon.Ctrl.SetEpiIcon(id, true);
  49. var info = EpigraphData.Instance.GetEpigraphInfo(id);
  50. if (info != null)
  51. {
  52. if (info.partnerId > 0)
  53. {
  54. var partnerTable = PartnerTableRepo.Get(info.partnerId);
  55. VM.IsBind.selectedIndex = 0;
  56. VM.PzLoader.url = AddressableDefine.EpigraphTypePz(table.Quality);
  57. VM.IconLoader.url = partnerTable?.Icon2;
  58. }
  59. else
  60. {
  61. VM.IsBind.selectedIndex = 1;
  62. }
  63. }
  64. else
  65. {
  66. VM.IsBind.selectedIndex = 1;
  67. }
  68. OnUpdateProgress();
  69. }
  70. private void OnUpdateProgress()
  71. {
  72. var info = EpigraphData.Instance.GetEpigraphInfo(id);
  73. var curlv = info != null ? info.starLv : 0;
  74. var table = epigraphUpTableRepo.GetEpiragphUp(id, curlv);
  75. if (table != null)
  76. {
  77. VM.ChipPbar.max = table.LevelUpCost;
  78. VM.ChipPbar.value = 0;
  79. }
  80. }
  81. }
  82. }