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> _gameobjects = new Dictionary>(); private Dictionary> _wrappers = new Dictionary>(); private GameObject _gameobject; private GoWrapper _wrapper; private GameObject _gameObject0; private GameObject _gameObject1; private GameObject _gameObject2; private GoWrapper _wrapper0; private GoWrapper _wrapper1; private GoWrapper _wrapper2; private int _effectIndex = 0; public override void Dispose() { base.Dispose(); // for (int i = 0; i < _gameobjects.Count; i++) // { // SceneController.DestroyObjectFromView(_gameobjects[i], _wrappers[i]); // } foreach (int key in _gameobjects.Keys) { foreach (int key1 in _gameobjects[key].Keys) { SceneController.DestroyObjectFromView(_gameobjects[key][key1], _wrappers[key][key1]); } } SceneController.DestroyObjectFromView(_gameobject, _wrapper); SceneController.DestroyObjectFromView(_gameObject0, _wrapper0); SceneController.DestroyObjectFromView(_gameObject1, _wrapper1); SceneController.DestroyObjectFromView(_gameObject2, _wrapper2); 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() { string resPath0 = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "bg_liuxing"); SceneController.AddObjectToView(null, null, _ui.m_holder_star, resPath0, out _gameObject0, out _wrapper0); string resPath1 = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "CK_UI"); SceneController.AddObjectToView(null, null, _ui.m_holder_bg, resPath1, out _gameObject1, out _wrapper1); string resPath2 = ResPathUtil.GetViewEffectPath("ui_LuckyBox", "bg_cloud"); SceneController.AddObjectToView(null, null, _ui.m_holder_cloud, resPath2, out _gameObject2, out _wrapper2); } 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); } else { _ui.m_c1.selectedIndex = 1; for (int i = 0; i < _rewardList.Count; i++) { UpdateItem(_ui.target.GetChild("item" + i).asCom, i); } } } protected override void OnHide() { base.OnHide(); _rewardList.Clear(); GetSuitItemController.TryShow(0); } private void UpdateItem(GComponent com, int index) { 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); if (itemCfg.rarity > 2 && (!_gameobjects.ContainsKey(itemCfg.rarity) || !_gameobjects[itemCfg.rarity].ContainsKey(index))) { string resPath = ResPathUtil.GetViewEffectPath("ui_LuckyBox", itemCfg.rarity == ConstDressRarity.Rarity_TIANYI ? "CK_all_01" : "CK_all_02"); if (!_gameobjects.ContainsKey(itemCfg.rarity)) { _gameobjects[itemCfg.rarity] = new Dictionary(); _wrappers[itemCfg.rarity] = new Dictionary(); } GGraph holder = itemCfg.rarity == 3 ? item.m_comIcon.m_holder : item.m_comIcon.m_holder1; SceneController.AddObjectToView(null, null, holder, resPath, out GameObject gameObject, out GoWrapper wrapper); _gameobjects[itemCfg.rarity][index] = gameObject; _wrappers[itemCfg.rarity][index] = wrapper; } 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); } } }