LuckyBoxBonusShowView.cs 5.4 KB

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