LuckyBoxBonusShowView.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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. // for (int i = 0; i < _gameobjects.Count; i++)
  25. // {
  26. // SceneController.DestroyObjectFromView(_gameobjects[i], _wrappers[i]);
  27. // }
  28. if (_ui != null)
  29. {
  30. _ui.Dispose();
  31. _ui = null;
  32. }
  33. }
  34. protected override void OnInit()
  35. {
  36. base.OnInit();
  37. packageName = UI_LuckBoxBonusShowUI.PACKAGE_NAME;
  38. _ui = UI_LuckBoxBonusShowUI.Create();
  39. this.viewCom = _ui.target;
  40. isfullScreen = true;
  41. _ui.m_loaBg.onClick.Add(this.Hide);
  42. _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zx_bg");
  43. UpdateEffect();
  44. }
  45. private void UpdateEffect()
  46. {
  47. _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holder_star, "ui_LuckyBox", "bg_liuxing");
  48. _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_holder_bg, "ui_LuckyBox", "CK_UI");
  49. _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_holder_cloud, "ui_LuckyBox", "bg_cloud");
  50. }
  51. protected override void OnShown()
  52. {
  53. base.OnShown();
  54. _rewardList.AddRange(this.viewData as List<ItemData>);
  55. _effectIndex = 0;
  56. if (_rewardList.Count == 1)
  57. {
  58. _ui.m_c1.selectedIndex = 0;
  59. UpdateItem(_ui.m_itemOne.target, 0, 1);
  60. }
  61. else
  62. {
  63. _ui.m_c1.selectedIndex = 1;
  64. for (int i = 0; i < _rewardList.Count; i++)
  65. {
  66. UpdateItem(_ui.target.GetChild("item" + i).asCom, i, 10);
  67. }
  68. }
  69. }
  70. protected override void OnHide()
  71. {
  72. for (int key = 0; key < _effList.Count; key++)
  73. {
  74. EffectUIPool.Recycle(_effList[key]);
  75. _effList[key] = null;
  76. }
  77. countEff = 0;
  78. _effList.Clear();
  79. EffectUIPool.Recycle(_effectUI1);
  80. _effectUI1 = null;
  81. EffectUIPool.Recycle(_effectUI2);
  82. _effectUI2 = null;
  83. EffectUIPool.Recycle(_effectUI3);
  84. _effectUI3 = null;
  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. }