using UI.LuckyBox; using UI.CommonGame; using System.Collections.Generic; using FairyGUI; namespace GFGGame { public class LuckyBoxPreShowView : BaseWindow { private UI_LuckyBoxPreShowUI _ui; private List _bonusList; public override void Dispose() { if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void OnInit() { base.OnInit(); _ui = UI_LuckyBoxPreShowUI.Create(); this.viewCom = _ui.target; this.viewCom.Center(); this.modal = true; } protected override void OnShown() { base.OnShown(); int boxId = (int)this.viewData; LuckyBoxCfg cfg = LuckyBoxCfgArray.Instance.GetCfg(boxId); string probShow = cfg.probShow.Replace("\\n", "\n"); _ui.m_compText.m_txtShow.text = probShow; _bonusList = LuckyBoxDataManager.Instance.GetCurrentShowList(boxId); _ui.m_list.RemoveChildrenToPool(); _ui.m_list.itemRenderer = ListItemRenderer; _ui.m_list.numItems = _bonusList.Count; } protected override void OnHide() { base.OnHide(); if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0); _ui.m_list.RemoveChildrenToPool(); } private void ListItemRenderer(int index, GObject item) { UI_CompLuckyBoxBonusListItem listItem = UI_CompLuckyBoxBonusListItem.Proxy(item); LuckyBoxBonusData luckyBoxBonusData = _bonusList[index]; listItem.m_txtName.text = luckyBoxBonusData.name; if (listItem.m_list.data == null) { listItem.m_list.itemRenderer = ListItemRewardRender; } listItem.m_list.data = luckyBoxBonusData.itemList; listItem.m_list.numItems = luckyBoxBonusData.itemList.Count; listItem.m_list.ResizeToFit(); listItem.target.height = listItem.m_list.y + listItem.m_list.height; UI_CompLuckyBoxBonusListItem.ProxyEnd(); } private void ListItemRewardRender(int index, GObject obj) { ItemData itemData = (obj.parent.data as List)[index]; if (obj.data == null) { obj.data = new ItemView(obj as GComponent); } (obj.data as ItemView).SetData(itemData); (obj.data as ItemView).ShowHasCount = false; (obj.data as ItemView).ImgHasVisible = ItemDataManager.GetItemNum(itemData.id) > 0; } } }