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 List _wrappers = new List(); private GameObject _gameobject; private GoWrapper _wrapper; private int _effectIndex = 0; public override void Dispose() { base.Dispose(); for (int i = 0; i < _gameobjects.Count; i++) { SceneController.DestroyObjectFromView(_gameobjects[i], _wrappers[i]); } SceneController.DestroyObjectFromView(_gameobject, _wrapper); 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"); } protected override void OnShown() { base.OnShown(); _rewardList.AddRange(this.viewData as List); _ui.m_c1.selectedIndex = _rewardList.Count == 1 ? 0 : 1; _effectIndex = 0; } protected override void OnHide() { base.OnHide(); } 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 = itemData.rarity; item.m_comIcon.m_txtName.text = itemCfg.name; item.m_comIcon.m_icon.url = ResPathUtil.GetIconPath(itemCfg); if (itemData.rarity > 2) { string resPath = ResPathUtil.GetViewEffectPath("ui_LuckyBox", itemData.rarity == ConstDressRarity.Rarity_TIANYI ? "CK_all_02" : "CK_all_01"); if (_effectIndex >= _gameobjects.Count) { GameObject gameObject = _gameobjects[_effectIndex]; GoWrapper wrapper = _wrappers[_effectIndex]; SceneController.AddObjectToView(gameObject, wrapper, item.m_comIcon.m_holder, resPath, out gameObject, out wrapper); } else { SceneController.AddObjectToView(null, null, item.m_comIcon.m_holder, resPath, out GameObject gameObject, out GoWrapper wrapper); _gameobjects.Add(gameObject); _wrappers.Add(wrapper); } _effectIndex++; } UI_LuckyBoxBonusShowItem.ProxyEnd(); } } }