using System.Collections.Generic; using FairyGUI; using UI.Task; using static GFGGame.ShopSProxy; namespace GFGGame { public class OpenBattlePassView : BaseWindow { private UI_OpenBattlePassUI _ui; public override void Dispose() { if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_OpenBattlePassUI.PACKAGE_NAME; _ui = UI_OpenBattlePassUI.Create(); viewCom = _ui.target; viewCom.Center(); _ui.m_CloseBtn.onClick.Add(Hide); // clickBlankToClose = false; _ui.m_Rewards.itemRenderer = SpecialRewardRender; _ui.m_OpenBtn.onClick.Add(OnBtnOpenClick); modal = true; } private void OnBtnOpenClick(EventContext context) { ReqShopBuy(990003).Coroutine(); } protected override void OnShown() { base.OnShown(); SetPrizeData(); } protected override void AddEventListener() { EventAgent.AddEventListener(ConstMessage.NOTICE_PASSPORT_OPEN, OnNoticePassportOpen); } protected override void RemoveEventListener() { EventAgent.RemoveEventListener(ConstMessage.NOTICE_PASSPORT_OPEN, OnNoticePassportOpen); } private void OnNoticePassportOpen() { Hide(); } private static void SpecialRewardRender(int index, GObject obj) { var itemInfos = (List>)obj.parent.data; var itemInfo = itemInfos[index]; ItemUtil.CreateItemView(new[] { itemInfo.Key, itemInfo.Value }, obj as GComponent); } private void SetPrizeData() { //获取所有特别奖励数据 var dataManager = BattlePassTaskDataManager.Instance; var allSpecialCfg = dataManager.GetAllSpecialCfg(); _ui.m_Rewards.data = allSpecialCfg; _ui.m_Rewards.numItems = allSpecialCfg.Count; } } }