TurnSpecialTipsView.cs 4.8 KB

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