TurnSpecialTipsView.cs 4.7 KB

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