using UnityEngine; using FairyGUI; using UI.LuckyBox; using System.Collections.Generic; using System.Collections; namespace GFGGame { public class LuckyBoxBonusShowView : BaseWindow { private UI_LuckBoxBonusShowUI _ui; private List _rewardList = new List(); // private List _gameobjects = new List(); //private Dictionary> _effList = new Dictionary>(); private Dictionary _effList = new Dictionary(); private int countEff = 0; private EffectUI _effectUI1; private EffectUI _effectUI2; private EffectUI _effectUI3; private EffectUI _effectUI4; private int _effectIndex = 0; public override void Dispose() { base.Dispose(); // for (int i = 0; i < _gameobjects.Count; i++) // { // SceneController.DestroyObjectFromView(_gameobjects[i], _wrappers[i]); // } if (_ui != null) { _ui.Dispose(); _ui = null; } } protected override void OnInit() { base.OnInit(); packageName = UI_LuckBoxBonusShowUI.PACKAGE_NAME; _ui = UI_LuckBoxBonusShowUI.Create(); this.viewCom = _ui.target; isfullScreen = true; _ui.m_loaBg.onClick.Add(this.Hide); _ui.m_loaBg.url = ResPathUtil.GetBgImgPath("zx_bg"); UpdateEffect(); } private void UpdateEffect() { _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holder_star, "ui_LuckyBox", "bg_liuxing"); _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_holder_bg, "ui_LuckyBox", "CK_UI"); _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_holder_cloud, "ui_LuckyBox", "bg_cloud"); } protected override void OnShown() { base.OnShown(); _rewardList.AddRange(this.viewData as List); _effectIndex = 0; if (_rewardList.Count == 1) { _ui.m_c1.selectedIndex = 0; UpdateItem(_ui.m_itemOne.target, 0, 1); } else { _ui.m_c1.selectedIndex = 1; for (int i = 0; i < _rewardList.Count; i++) { UpdateItem(_ui.target.GetChild("item" + i).asCom, i, 10); } } } protected override void OnHide() { for (int key = 0; key < _effList.Count; key++) { EffectUIPool.Recycle(_effList[key]); _effList[key] = null; } countEff = 0; _effList.Clear(); EffectUIPool.Recycle(_effectUI1); _effectUI1 = null; EffectUIPool.Recycle(_effectUI2); _effectUI2 = null; EffectUIPool.Recycle(_effectUI3); _effectUI3 = null; EffectUIPool.Recycle(_effectUI4); _effectUI4 = null; base.OnHide(); _rewardList.Clear(); GetSuitItemController.TryShow(0); } private void UpdateItem(GComponent com, int index, int countType) { UI_LuckyBoxBonusShowItem item = UI_LuckyBoxBonusShowItem.Proxy(com); ItemData itemData = _rewardList[index]; ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id); item.m_comIcon.m_c1.selectedIndex = itemCfg.rarity; item.m_comIcon.m_txtName.text = itemCfg.name; item.m_comIcon.m_icon.url = ResPathUtil.GetIconPath(itemCfg); RarityIconController.UpdateRarityIcon(item.m_comIcon.m_rarity, itemData.id, false); string resPath = itemCfg.rarity == ConstDressRarity.Rarity_TIANYI ? "CK_all_01" : "CK_all_02"; if (countType == 10 && itemCfg.rarity > 2 )//&& (!_effList.ContainsKey(itemCfg.rarity) || !_effList[itemCfg.rarity].ContainsKey(index))) { GGraph holder = itemCfg.rarity == 3 ? item.m_comIcon.m_holder : item.m_comIcon.m_holder1; EffectUI _effectUI = EffectUIPool.CreateEffectUI(holder, "ui_LuckyBox", resPath); _effList.Add(countEff , _effectUI); countEff += 1; } if (countType == 1 && itemCfg.rarity > 2 && _effectUI4 == null) { GGraph holder = itemCfg.rarity == 3 ? item.m_comIcon.m_holder : item.m_comIcon.m_holder1; _effectUI4 = EffectUIPool.CreateEffectUI(holder, "ui_LuckyBox", resPath); } int count = 0; bool isFirst = false; for (int i = 0; i < _rewardList.Count; i++) { if (_rewardList[i].id == itemData.id) count++; if (count == 1 && i == index) isFirst = true; } item.m_comIcon.m_imgNew.visible = count == ItemDataManager.GetItemNum(itemData.id) && isFirst; item.m_t0.Play(); if (item.target.data == null) { item.target.onClick.Add(ShowItemTips); } item.target.data = itemCfg.id; UI_LuckyBoxBonusShowItem.ProxyEnd(); } private void ShowItemTips(EventContext context) { GObject obj = context.sender as GObject; int itemID = (int)obj.data; GoodsItemTipsController.ShowItemTips(itemID); } } }