123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- 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<ShopCfg> _shopCfgs;
- private List<EffectUI> _effectUIs = new List<EffectUI>();
- 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 itemIdCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId);
- ItemCfg doubleItem = ItemCfgArray.Instance.GetCfg(shopCfg.doubleItemId);
- item.m_txtName.text = string.Format("{0}{1}", shopCfg.itemNum, itemIdCfg.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);
- }
- }
- }
- }
|