LuckyBoxBonusShowView.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. using UnityEngine;
  2. using FairyGUI;
  3. using UI.LuckyBox;
  4. using System.Collections.Generic;
  5. using System.Collections;
  6. namespace GFGGame
  7. {
  8. public class LuckyBoxBonusShowView : BaseWindow
  9. {
  10. private UI_LuckBoxBonusShowUI _ui;
  11. private List<ItemData> _rewardList = new List<ItemData>();
  12. // private List<GameObject> _gameobjects = new List<GameObject>();
  13. //private Dictionary<int, Dictionary<int, EffectUI>> _effList = new Dictionary<int, Dictionary<int, EffectUI>>();
  14. private Dictionary<int, EffectUI> _effList = new Dictionary<int, EffectUI>();
  15. private int countEff = 0;
  16. private EffectUI _effectUI1;
  17. private EffectUI _effectUI2;
  18. private EffectUI _effectUI3;
  19. private EffectUI _effectUI4;
  20. private int _effectIndex = 0;
  21. public override void Dispose()
  22. {
  23. base.Dispose();
  24. EffectUIPool.Recycle(_effectUI1);
  25. _effectUI1 = null;
  26. EffectUIPool.Recycle(_effectUI2);
  27. _effectUI2 = null;
  28. EffectUIPool.Recycle(_effectUI3);
  29. _effectUI3 = null;
  30. // for (int i = 0; i < _gameobjects.Count; i++)
  31. // {
  32. // SceneController.DestroyObjectFromView(_gameobjects[i], _wrappers[i]);
  33. // }
  34. if (_ui != null)
  35. {
  36. _ui.Dispose();
  37. _ui = null;
  38. }
  39. }
  40. protected override void OnInit()
  41. {
  42. base.OnInit();
  43. packageName = UI_LuckBoxBonusShowUI.PACKAGE_NAME;
  44. _ui = UI_LuckBoxBonusShowUI.Create();
  45. this.viewCom = _ui.target;
  46. isfullScreen = true;
  47. _ui.m_loaBg.onClick.Add(this.Hide);
  48. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zx_bg");
  49. UpdateEffect();
  50. }
  51. private void UpdateEffect()
  52. {
  53. _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holder_star, "ui_LuckyBox", "bg_liuxing");
  54. _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_holder_bg, "ui_LuckyBox", "CK_UI");
  55. _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_holder_cloud, "ui_LuckyBox", "bg_cloud");
  56. }
  57. protected override void OnShown()
  58. {
  59. base.OnShown();
  60. _rewardList.AddRange(this.viewData as List<ItemData>);
  61. _effectIndex = 0;
  62. if (_rewardList.Count == 1)
  63. {
  64. _ui.m_c1.selectedIndex = 0;
  65. UpdateItem(_ui.m_itemOne.target, 0, 1);
  66. }
  67. else
  68. {
  69. _ui.m_c1.selectedIndex = 1;
  70. for (int i = 0; i < _rewardList.Count; i++)
  71. {
  72. UpdateItem(_ui.target.GetChild("item" + i).asCom, i, 10);
  73. }
  74. }
  75. }
  76. protected override void OnHide()
  77. {
  78. for (int key = 0; key < _effList.Count; key++)
  79. {
  80. EffectUIPool.Recycle(_effList[key]);
  81. _effList[key] = null;
  82. }
  83. countEff = 0;
  84. _effList.Clear();
  85. EffectUIPool.Recycle(_effectUI4);
  86. _effectUI4 = null;
  87. base.OnHide();
  88. _rewardList.Clear();
  89. GetSuitItemController.TryShow(0);
  90. }
  91. private void UpdateItem(GComponent com, int index, int countType)
  92. {
  93. UI_LuckyBoxBonusShowItem item = UI_LuckyBoxBonusShowItem.Proxy(com);
  94. ItemData itemData = _rewardList[index];
  95. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id);
  96. item.m_comIcon.m_c1.selectedIndex = itemCfg.rarity;
  97. item.m_comIcon.m_txtName.text = itemCfg.name;
  98. item.m_comIcon.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
  99. RarityIconController.UpdateRarityIcon(item.m_comIcon.m_rarity, itemData.id, false);
  100. string resPath = itemCfg.rarity == ConstDressRarity.Rarity_TIANYI ? "CK_all_01" : "CK_all_02";
  101. if (countType == 10 && itemCfg.rarity > 2 )//&& (!_effList.ContainsKey(itemCfg.rarity) || !_effList[itemCfg.rarity].ContainsKey(index)))
  102. {
  103. GGraph holder = itemCfg.rarity == 3 ? item.m_comIcon.m_holder : item.m_comIcon.m_holder1;
  104. EffectUI _effectUI = EffectUIPool.CreateEffectUI(holder, "ui_LuckyBox", resPath);
  105. _effList.Add(countEff , _effectUI);
  106. countEff += 1;
  107. }
  108. if (countType == 1 && itemCfg.rarity > 2 && _effectUI4 == null)
  109. {
  110. GGraph holder = itemCfg.rarity == 3 ? item.m_comIcon.m_holder : item.m_comIcon.m_holder1;
  111. _effectUI4 = EffectUIPool.CreateEffectUI(holder, "ui_LuckyBox", resPath);
  112. }
  113. int count = 0;
  114. bool isFirst = false;
  115. for (int i = 0; i < _rewardList.Count; i++)
  116. {
  117. if (_rewardList[i].id == itemData.id) count++;
  118. if (count == 1 && i == index) isFirst = true;
  119. }
  120. item.m_comIcon.m_imgNew.visible = count == ItemDataManager.GetItemNum(itemData.id) && isFirst;
  121. item.m_t0.Play();
  122. if (item.target.data == null)
  123. {
  124. item.target.onClick.Add(ShowItemTips);
  125. }
  126. item.target.data = itemCfg.id;
  127. UI_LuckyBoxBonusShowItem.ProxyEnd();
  128. }
  129. private void ShowItemTips(EventContext context)
  130. {
  131. GObject obj = context.sender as GObject;
  132. int itemID = (int)obj.data;
  133. GoodsItemTipsController.ShowItemTips(itemID);
  134. }
  135. }
  136. }