1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- 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);
- }
- 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<KeyValuePair<int, int>>)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;
- }
- }
- }
|