using System.Collections.Generic; using ET; using FairyGUI; using UI.DailyWelfare; using UI.CommonGame; using UnityEngine; namespace GFGGame { public class FirstChargeBonusView : BaseWindow { private UI_FirstChargeBonusUI _ui; public override void Dispose() { if (_ui != null) { _ui.Dispose(); _ui = null; } base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_FirstChargeBonusUI.PACKAGE_NAME; _ui = UI_FirstChargeBonusUI.Create(); this.viewCom = _ui.target; this.modal = true; this.viewCom.Center(); viewAnimationType = EnumViewAnimationType.ZOOM_CENTER; _ui.m_list.itemRenderer = ListItemRender; _ui.m_btnCharge.onClick.Add(OnBtnChargeClick); _ui.m_btnGet.onClick.Add(OnBtnGetClick); } protected override void OnShown() { base.OnShown(); } protected override void OnHide() { base.OnHide(); if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0); } private void OnBtnChargeClick() { } private async void OnBtnGetClick() { bool result = await ActivitySProxy.ReqFirstChargeBonusRewards(); if (result) { UpdateView(); } } private void UpdateView() { _ui.m_list.numItems = GlobalCfgArray.globalCfg.firstChargeBonusArr.Length; _ui.m_c1.selectedIndex = ActivityDataManager.Instance.firstChargeBonusStatus; } private void ListItemRender(int index, GObject obj) { UI_ComItem item = UI_ComItem.Proxy(obj); int[] reward = GlobalCfgArray.globalCfg.firstChargeBonusArr[index]; ItemData itemData = ItemUtil.createItemData(reward); if (obj.data == null) { obj.data = new ItemView(obj as GComponent); } (obj.data as ItemView).SetData(itemData); UI_ComItem.ProxyEnd(); } } }