using UI.Store; using UI.CommonGame; using FairyGUI; using System.Collections.Generic; using ET; namespace GFGGame { public class StoreChargeView : BaseWindow { private UI_StoreChargeUI _ui; private ValueBarController _valueBarController; private List _shopCfgs; private List _effectUIs = new List(); public override void Dispose() { if (_valueBarController != null) { _valueBarController.Dispose(); _valueBarController = null; } if (_ui != null) { _ui.Dispose(); } _ui = null; base.Dispose(); } protected override void OnInit() { base.OnInit(); packageName = UI_StoreChargeUI.PACKAGE_NAME; _ui = UI_StoreChargeUI.Create(); this.viewCom = _ui.target; isfullScreen = true; this.clickBlankToClose = false; this.bringToFontOnClick = false; _ui.m_list.itemRenderer = ListItemRenderer; _valueBarController = new ValueBarController(_ui.m_valueBar); } protected override void AddEventListener() { base.AddEventListener(); EventAgent.AddEventListener(ConstMessage.SHOP_BUY, UpdateView); } protected override void OnShown() { base.OnShown(); _shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(ConstStoreTabId.STORE_CHARGE, ConstStoreSubId.STORE_CHARGE); _valueBarController.OnShown(); _ui.m_comVipLv.m_loaIcon.url = ResPathUtil.GetIconPath("tb_hyjf", "png"); UpdateView(); } private void DestroyEffect() { for (int i = 0; i < _effectUIs.Count; i++) { EffectUIPool.Recycle(_effectUIs[i]); _effectUIs[i] = null; } _effectUIs.Clear(); } private void UpdateView() { DestroyEffect(); _ui.m_list.numItems = _shopCfgs.Count; ShopViewManager.Instance.UpdateVipProgressCom(_ui.m_comVipLv.target); } protected override void OnHide() { base.OnHide(); DestroyEffect(); _valueBarController.OnHide(); } protected override void RemoveEventListener() { base.RemoveEventListener(); EventAgent.RemoveEventListener(ConstMessage.SHOP_BUY, UpdateView); } private void ListItemRenderer(int index, GObject obj) { ShopCfg shopCfg = _shopCfgs[index]; UI_ListChargeItem item = UI_ListChargeItem.Proxy(obj); item.m_btnBuy.m_c1.selectedIndex = 1; item.m_btnBuy.m_txtTitle.text = shopCfg.price.ToString(); if (item.target.data == null) { item.target.onClick.Add(OnClickBtnBuy); } item.target.data = index; ItemCfg doubleItem = ItemCfgArray.Instance.GetCfg(shopCfg.doubleItemId); item.m_txtName.text = string.Format("{0}{1}", shopCfg.itemNum, doubleItem.name); item.m_txtDesc.text = string.Format("首充赠送+{0}{1}", shopCfg.itemNum, doubleItem.name); bool isDouble = ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id) < shopCfg.doubleTimes; item.m_grpDouble.visible = isDouble; item.m_txtDesc.visible = isDouble; item.m_icon.url = "ui://Store/sc_zizhuan_" + (index + 1); if (isDouble) { EffectUI _effectUI = EffectUIPool.CreateEffectUI(item.m_holderfEff, "ui_Small_parts", "store_FirstCharge_Double"); _effectUIs.Add(_effectUI); item.m_holderfEff.visible = isDouble; } UI_ListChargeItem.ProxyEnd(); } private void OnClickBtnBuy(EventContext context) { GObject obj = context.sender as GObject; int index = (int)obj.data; ShopCfg itemData = _shopCfgs[index]; if (!AntiAddictionController.CheckAntiAddictionRecharge(itemData.price)) { ShopSProxy.ReqShopBuy(itemData.id, 1).Coroutine(); LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2); } } } }