12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using UI.LuckyBox;
- using UI.CommonGame;
- using System.Collections.Generic;
- using FairyGUI;
- namespace GFGGame
- {
- public class LuckyBoxPreShowView : BaseWindow
- {
- private UI_LuckyBoxPreShowUI _ui;
- private List<LuckyBoxBonusData> _bonusList;
- public override void Dispose()
- {
- 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();
- string probShow = LuckyBoxDataManager.Instance.probShow;
- probShow = probShow.Replace("\\n", "\n");
- _ui.m_compText.m_txtShow.text = probShow;
- _bonusList = LuckyBoxDataManager.Instance.GetCurrentShowList();
- _ui.m_list.RemoveChildrenToPool();
- _ui.m_list.itemRenderer = ListItemRenderer;
- _ui.m_list.numItems = _bonusList.Count;
- }
- protected override void OnHide()
- {
- base.OnHide();
- _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;
- listItem.m_list.itemRenderer = (int index, GObject item) =>
- {
- UI_BonusItem1 goodsItem = UI_BonusItem1.Proxy(item);
- ItemData itemData = luckyBoxBonusData.itemList[index] as ItemData;
- ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(itemData.id);
- goodsItem.m_iconOwned.visible = ItemDataManager.GetItemNum(itemData.id) > 0;
- goodsItem.m_txtName.text = itemCfg.name;
- goodsItem.m_iconItem.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
- RarityIconController.UpdateRarityIcon(goodsItem.m_iconItem.m_rarity, itemData.id, true);
- goodsItem.target.data = itemData.id;
- };
- listItem.m_list.onClickItem.Add((EventContext context) =>
- {
- GComponent item = context.data as GComponent;
- int itemID = (int)item.data;
- GoodsItemTipsController.ShowItemTips(itemID);
- });
- listItem.m_list.numItems = luckyBoxBonusData.itemList.Count;
- listItem.m_list.ResizeToFit();
- listItem.target.height = listItem.m_list.y + listItem.m_list.height;
- }
- }
- }
|