| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 | 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<ItemData> _rewardList = new List<ItemData>();        private List<GameObject> _gameobjects = new List<GameObject>();        private List<GoWrapper> _wrappers = new List<GoWrapper>();        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]);            }            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<ItemData>);            _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)            {                string resPath = ResPathUtil.GetViewEffectPath("ui_LuckyBox", itemCfg.rarity == ConstDressRarity.Rarity_TIANYI ? "CK_all_01" : "CK_all_02");                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++;            }            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);        }    }}
 |