PartnerBookDetailListItemCtrl.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 = new ItemBase();
  51. item.Init(table.Reward[0], table.Reward[1]);
  52. VM.ItemBtn.Ctrl.ShowUI(item);
  53. var list = new List<PartnerBookTextParam>();
  54. for (int i = 0; i < table.Attribute.Length; i += 2)
  55. {
  56. list.Add(
  57. new PartnerBookTextParam()
  58. {
  59. attrId = table.Attribute[i],
  60. val = table.Attribute[i + 1],
  61. }
  62. );
  63. }
  64. VM.List.BindDatas(list);
  65. var collect = collectTableRepo.Get(table.CollectId);
  66. XGame.Framework.Assert.IsNotNull(collect);
  67. var starLv = 0;
  68. foreach (var id in collect.Param)
  69. {
  70. if (
  71. collect.Type == 1
  72. && PartnersData.Instance.TryGetPartnerAttrByTableId(id, out var attr)
  73. )
  74. {
  75. starLv += attr.RisingStarLv;
  76. }
  77. else if (
  78. collect.Type == 2
  79. && EpigraphData.Instance.TryGetEpigraphAttrByTableId(id, out var epi)
  80. )
  81. {
  82. starLv += epi.StarLv;
  83. }
  84. }
  85. if (starLv >= table.Unlock)
  86. {
  87. if (collect.Type == 1)
  88. {
  89. if (PartnersData.Instance.GetJibaIsActive(table.CollectId, table.Level))
  90. {
  91. VM.State.selectedIndex = 2;
  92. }
  93. else
  94. {
  95. VM.State.selectedIndex = 1;
  96. }
  97. }
  98. else if (collect.Type == 2)
  99. {
  100. if (EpigraphData.Instance.GetJibaIsActive(table.CollectId, table.Level))
  101. {
  102. VM.State.selectedIndex = 2;
  103. }
  104. else
  105. {
  106. VM.State.selectedIndex = 1;
  107. }
  108. }
  109. }
  110. else
  111. {
  112. VM.State.selectedIndex = 0;
  113. }
  114. }
  115. }
  116. }