123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- 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 Dictionary<int, Dictionary<int, GameObject>> _gameobjects = new Dictionary<int, Dictionary<int, GameObject>>();
- private Dictionary<int, Dictionary<int, GoWrapper>> _wrappers = new Dictionary<int, Dictionary<int, GoWrapper>>();
- 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]);
- // }
- foreach (int key in _gameobjects.Keys)
- {
- foreach (int key1 in _gameobjects[key].Keys)
- {
- SceneController.DestroyObjectFromView(_gameobjects[key][key1], _wrappers[key][key1]);
- }
- }
- EffectUIPool.Recycle(_effectUI1);
- _effectUI1 = null;
- EffectUIPool.Recycle(_effectUI2);
- _effectUI2 = null;
- EffectUIPool.Recycle(_effectUI3);
- _effectUI3 = null;
- EffectUIPool.Recycle(_effectUI4);
- _effectUI4 = null;
- 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<ItemData>);
- _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()
- {
- 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 && (!_gameobjects.ContainsKey(itemCfg.rarity) || !_gameobjects[itemCfg.rarity].ContainsKey(index)))
- {
- if (!_gameobjects.ContainsKey(itemCfg.rarity))
- {
- _gameobjects[itemCfg.rarity] = new Dictionary<int, GameObject>();
- _wrappers[itemCfg.rarity] = new Dictionary<int, GoWrapper>();
- }
- 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;
- }
- 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);
- }
- }
- }
|