| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 | 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<StoreView>(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.FirstRechargeTotal)            {                UpdateView();            }        }        private void UpdateView()        {            _ui.m_c1.selectedIndex = ActivityDataManager.Instance.firstChargeBonusStatus;        }        private void ListItemRender(int index, GObject 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);        }    }}
 |