PartnerBookDetailListItemCtrl.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 FL.Data.Items;
  10. using XGame.Database;
  11. using XGame.Framework.UI;
  12. namespace FL.FGUI
  13. {
  14. /// <summary>
  15. /// UI逻辑处理类
  16. /// </summary>
  17. /// <typeparam name=""></typeparam>
  18. public partial class PartnerBookDetailListItemCtrl : UIController<PartnerBookDetailListItemVM>
  19. {
  20. protected override void OnEnable(object intent)
  21. {
  22. AddUIListenres();
  23. }
  24. protected override void OnDisable()
  25. {
  26. RemoveUIListenres();
  27. }
  28. #region UI事件
  29. private void AddUIListenres()
  30. {
  31. VM.GotoBtn.onClick.Add(OnClickGotoBtn);
  32. VM.GetBtn.onClick.Add(OnClickGetBtn);
  33. }
  34. private void RemoveUIListenres()
  35. {
  36. VM.GotoBtn.onClick.Remove(OnClickGotoBtn);
  37. VM.GetBtn.onClick.Remove(OnClickGetBtn);
  38. }
  39. private void OnClickGotoBtn(EventContext context) { }
  40. private void OnClickGetBtn(EventContext context)
  41. {
  42. PartnersService.Instance.RequestJibanRwdGet(_id);
  43. }
  44. #endregion
  45. private int _id;
  46. public void OnRefresh(int index, collect_rewardTable table)
  47. {
  48. _id = table.Id;
  49. VM.DescLabel.text = table.Name;
  50. var item = ItemBase.Create(table.Reward[0], table.Reward[1]);
  51. VM.ItemBtn.Ctrl.ShowUI(item);
  52. var list = new List<PartnerBookTextParam>();
  53. for (int i = 0; i < table.Attribute.Length; i += 2)
  54. {
  55. list.Add(
  56. new PartnerBookTextParam()
  57. {
  58. attrId = table.Attribute[i],
  59. val = table.Attribute[i + 1],
  60. }
  61. );
  62. }
  63. VM.List.BindDatas(list);
  64. var collect = collectTableRepo.Get(table.CollectId);
  65. XGame.Framework.Assert.IsNotNull(collect);
  66. var starLv = 0;
  67. foreach (var id in collect.Param)
  68. {
  69. if (
  70. collect.Type == 1
  71. && PartnersData.Instance.TryGetPartnerAttrByTableId(id, out var attr)
  72. )
  73. {
  74. starLv += attr.RisingStarLv;
  75. }
  76. else if (
  77. collect.Type == 2
  78. && EpigraphData.Instance.TryGetEpigraphAttrByTableId(id, out var epi)
  79. )
  80. {
  81. starLv += epi.StarLv;
  82. }
  83. }
  84. if (starLv >= table.Unlock)
  85. {
  86. if (collect.Type == 1)
  87. {
  88. if (PartnersData.Instance.GetJibaIsActive(table.CollectId, table.Level))
  89. {
  90. VM.State.selectedIndex = 2;
  91. }
  92. else
  93. {
  94. VM.State.selectedIndex = 1;
  95. }
  96. }
  97. else if (collect.Type == 2)
  98. {
  99. if (EpigraphData.Instance.GetJibaIsActive(table.CollectId, table.Level))
  100. {
  101. VM.State.selectedIndex = 2;
  102. }
  103. else
  104. {
  105. VM.State.selectedIndex = 1;
  106. }
  107. }
  108. }
  109. else
  110. {
  111. VM.State.selectedIndex = 0;
  112. }
  113. }
  114. }
  115. }