using ET; using FairyGUI; using UI.BornLimit; using UI.CommonGame; 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); _ui.m_btnClose.onClick.Add(closeEventHandler); } protected override void AddEventListener() { base.AddEventListener(); EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, OnNumericChange); } protected override void RemoveEventListener() { base.RemoveEventListener(); EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, OnNumericChange); } protected override void OnShown() { base.OnShown(); _ui.m_list.numItems = GlobalCfgArray.globalCfg.firstChargeBonusArr.Length; var itemInfo = GlobalCfgArray.globalCfg.firstChargeBonusArr[0]; var itemId = itemInfo[0]; var itemCfg = ItemCfgArray.Instance.GetCfg(itemId); if(itemCfg.suitId > 0) { var suitCfg = SuitCfgArray.Instance.GetCfg(itemCfg.suitId); _ui.m_txtName.text = suitCfg.name; } UpdateView(); } protected override void OnHide() { base.OnHide(); if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0); } private void OnBtnChargeClick() { ViewManager.Show(new object[] { ConstStoreTabId.STORE_CHARGE, ConstStoreSubId.STORE_CHARGE }); } private async void OnBtnGetClick() { bool result = await ActivitySProxy.ReqFirstChargeBonusRewards(); if (result) { UpdateView(); } } private void OnNumericChange(EventContext context) { var status = (int)context.data; if (status == NumericType.FirstRechargeBonusStatus || status == NumericType.RechargeTotal) { UpdateView(); } } private void UpdateView() { _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(); } } }