TurnSpecialTipsView.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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 = ActivityDataManager.Instance.TipsDropId;//TurntableLuckyBoxCfgArray.Instance.GetCfgByActivityId(activityID).ExtraIdDropId;
  50. rewardList =CommonDataManager.Tables.TblDropOutCfg.GetGroup1ById(dropId);
  51. _ui.m_list.numItems = rewardList.Count;
  52. }
  53. protected override void OnHide()
  54. {
  55. base.OnHide();
  56. }
  57. private void RenderTaskList(int index, GObject obj)
  58. {
  59. ItemParam itemParam = new ItemParam() { ItemId = rewardList[index].Item,Count =rewardList[index].MaxNum };
  60. ItemData reward = ItemUtil.createItemData(itemParam);
  61. if (obj.data == null)
  62. {
  63. obj.data = new ItemView(obj as GComponent);
  64. }
  65. (obj.data as ItemView).SetData(reward);
  66. (obj.data as ItemView).ChangeTxtCountStyle();
  67. if(isGetBag(reward.id))
  68. {
  69. (obj.data as ItemView).ImgHasVisible = true;
  70. }
  71. else
  72. {
  73. (obj.data as ItemView).ImgHasVisible = false;
  74. }
  75. }
  76. private bool isGetGift(int id)
  77. {
  78. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(id);
  79. if (itemCfg == null)
  80. {
  81. return false;
  82. }
  83. //int targetCount = itemCfg.itemsArr.Length;
  84. int targetCount = itemCfg.Items.Count;
  85. int count = 0;
  86. for (int i = 0; i < itemCfg.Items.Count; i++)
  87. {
  88. ItemData itemDate;
  89. if (BagDataManager.Instance.GetBagData().TryGetValue(itemCfg.Items[i].ItemId, out itemDate))
  90. {
  91. if (itemDate.num >= itemCfg.Items[i].Count)
  92. {
  93. count++;
  94. }
  95. }
  96. else
  97. {
  98. ItemCfg itemcfg =CommonDataManager.Tables.TblItemCfg.GetOrDefault(itemCfg.Items[i].ItemId);
  99. if(itemcfg.ItemType == ConstItemType.CARD)
  100. {
  101. CardData data = CardDataManager.GetCardDataById(itemcfg.Id);
  102. if(data !=null)
  103. {
  104. count++;
  105. }
  106. }
  107. else if(itemcfg.ItemType == ConstItemType.ITEM && itemcfg.SubType == 1)
  108. {
  109. }
  110. else
  111. {
  112. if (ItemDataManager.GetItemNum(itemCfg.Items[i].ItemId) >= itemCfg.Items[i].Count)
  113. {
  114. count++;
  115. }
  116. }
  117. }
  118. }
  119. if(count >= targetCount)
  120. {
  121. return true;
  122. }
  123. return false;
  124. }
  125. private bool isGetBag(int id)
  126. {
  127. foreach(var item in ActivityDataManager.Instance.GiftBagIdList)
  128. {
  129. if(item == id)
  130. {
  131. return true;
  132. }
  133. }
  134. return false;
  135. }
  136. }
  137. }