LuckyBoxBonusShowView.cs 4.6 KB

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