TurnSpecialTipsView.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using UnityEngine;
  2. using FairyGUI;
  3. using UI.TurnTable;
  4. using System.Collections.Generic;
  5. using cfg;
  6. using cfg.GfgCfg;
  7. namespace GFGGame
  8. {
  9. public class TurnSpecialTipsView : BaseWindow
  10. {
  11. private UI_TurnSpecialTipsUI _ui;
  12. public List<DropOutCfg> rewardList = new List<DropOutCfg>();
  13. private EffectUI _effectUI1;
  14. private EffectUI _effectUI2;
  15. public override void Dispose()
  16. {
  17. EffectUIPool.Recycle(_effectUI1);
  18. _effectUI1 = null;
  19. EffectUIPool.Recycle(_effectUI2);
  20. _effectUI2 = null;
  21. base.Dispose();
  22. if (_ui != null)
  23. {
  24. _ui.Dispose();
  25. _ui = null;
  26. }
  27. base.Dispose();
  28. }
  29. protected override void Init()
  30. {
  31. base.Init();
  32. }
  33. protected override void OnInit()
  34. {
  35. base.OnInit();
  36. packageName = UI_TurnSpecialTipsUI.PACKAGE_NAME;
  37. _ui = UI_TurnSpecialTipsUI.Create();
  38. viewCom = _ui.target;
  39. modal = true;
  40. this.viewCom.Center();
  41. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  42. _ui.m_list.itemRenderer = RenderTaskList;
  43. }
  44. protected override void OnShown()
  45. {
  46. base.OnShown();
  47. //这里根据表来,看放哪
  48. //int activityID = ActivityDataManager.Instance.GetCurOpenActiveByType(ActivityDataManager.Instance.TurnTableActivityType);
  49. int dropId =
  50. ActivityDataManager.Instance
  51. .TipsDropId; //TurntableLuckyBoxCfgArray.Instance.GetCfgByActivityId(activityID).ExtraIdDropId;
  52. rewardList = CommonDataManager.Tables.TblDropOutCfg.GetGroup1ById(dropId);
  53. _ui.m_list.numItems = rewardList.Count;
  54. }
  55. protected override void OnHide()
  56. {
  57. base.OnHide();
  58. }
  59. private void RenderTaskList(int index, GObject obj)
  60. {
  61. ItemParamProto itemParam = new ItemParamProto()
  62. { ItemId = rewardList[index].Item, Count = rewardList[index].MaxNum };
  63. ItemData reward = ItemUtil.createItemData(itemParam);
  64. if (obj.data == null)
  65. {
  66. obj.data = new ItemView(obj as GComponent);
  67. }
  68. (obj.data as ItemView).SetData(reward);
  69. (obj.data as ItemView).ChangeTxtCountStyle();
  70. if (isGetBag(reward.id))
  71. {
  72. (obj.data as ItemView).ImgHasVisible = true;
  73. }
  74. else
  75. {
  76. (obj.data as ItemView).ImgHasVisible = false;
  77. }
  78. }
  79. private bool isGetGift(int id)
  80. {
  81. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(id);
  82. if (itemCfg == null)
  83. {
  84. return false;
  85. }
  86. //int targetCount = itemCfg.itemsArr.Length;
  87. int targetCount = itemCfg.Items.Count;
  88. int count = 0;
  89. for (int i = 0; i < itemCfg.Items.Count; i++)
  90. {
  91. ItemData itemDate;
  92. if (BagDataManager.Instance.GetBagData().TryGetValue(itemCfg.Items[i].ItemId, out itemDate))
  93. {
  94. if (itemDate.num >= itemCfg.Items[i].Count)
  95. {
  96. count++;
  97. }
  98. }
  99. else
  100. {
  101. ItemCfg itemcfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(itemCfg.Items[i].ItemId);
  102. if (itemcfg.ItemType == ConstItemType.CARD)
  103. {
  104. CardData data = CardDataManager.GetCardDataById(itemcfg.Id);
  105. if (data != null)
  106. {
  107. count++;
  108. }
  109. }
  110. else if (itemcfg.ItemType == ConstItemType.ITEM && itemcfg.SubType == 1)
  111. {
  112. }
  113. else
  114. {
  115. if (ItemDataManager.GetItemNum(itemCfg.Items[i].ItemId) >= itemCfg.Items[i].Count)
  116. {
  117. count++;
  118. }
  119. }
  120. }
  121. }
  122. if (count >= targetCount)
  123. {
  124. return true;
  125. }
  126. return false;
  127. }
  128. private bool isGetBag(int id)
  129. {
  130. foreach (var item in ActivityDataManager.Instance.GiftBagIdList)
  131. {
  132. if (item == id)
  133. {
  134. return true;
  135. }
  136. }
  137. return false;
  138. }
  139. }
  140. }