using System; using System.Collections.Generic; using ET; using FairyGUI; using UI.Store; namespace GFGGame { public class ShopViewManager : SingletonBase { public void BuyItem(int itemId, int itemCount, int buyType, ShopCfg shopCfg) { BuyItemConteoller.Show(itemId, itemCount, buyType, () => { LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.FU_ZHUANG_DIAN, 2); GetSuitItemController.TryShow(0); }, true, false, GameConst.MAX_COUNT_TO_BUY_ITEMS); } //更行vip进度 public void UpdateVipProgressCom(GObject obj) { UI_ComVipLv com = UI_ComVipLv.Proxy(obj); com.m_txtLv.text = RoleDataManager.vipLv.ToString(); int level = RoleDataManager.vipLv; ET.Log.Debug("vipLv:" + level); ET.Log.Debug("vipExp:" + RoleDataManager.vipExp); VipCfg vipCfg = VipCfgArray.Instance.GetCfg(RoleDataManager.vipLv); if (vipCfg == null) return; VipCfg nextVipCfg = VipCfgArray.Instance.GetCfg(RoleDataManager.vipLv + 1); com.m_grpTips.visible = nextVipCfg != null; if (com.m_btnRule.data == null) { com.m_btnRule.onClick.Add(RuleController.ShowRuleView); com.m_btnRule.data = 300009; } if (nextVipCfg != null) { com.m_proExp.target.max = vipCfg.num; com.m_proExp.target.value = RoleDataManager.vipExp; com.m_proExp.m_txttitle.SetVar("value", com.m_proExp.target.value.ToString()).FlushVars(); com.m_proExp.m_txttitle.SetVar("max", com.m_proExp.target.max.ToString()).FlushVars(); com.m_txtTips.SetVar("exp", (vipCfg.num - RoleDataManager.vipExp).ToString()).FlushVars(); com.m_txtTips.SetVar("vipLv", (nextVipCfg.id).ToString()).FlushVars(); } else { com.m_proExp.target.max = vipCfg.num; com.m_proExp.target.value = RoleDataManager.vipExp; com.m_proExp.m_txttitle.SetVar("value", com.m_proExp.target.value.ToString()).FlushVars(); com.m_proExp.m_txttitle.SetVar("max", "MAX").FlushVars(); } UI_ComVipLv.ProxyEnd(); } private List _effectUIs = new List(); //清除商品item的特效 public void ClearItemEff() { for (int i = 0; i < _effectUIs.Count; i++) { EffectUIPool.Recycle(_effectUIs[i]); _effectUIs[i] = null; } _effectUIs.Clear(); } //更新商品item public void UptadeItem(GObject obj, ShopCfg shopCfg) { UI_ListShopItem item = UI_ListShopItem.Proxy(obj); ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId); item.m_txtName.text = shopCfg.itemName; item.m_icon.url = ResPathUtil.GetIconPath(itemCfg); item.m_grpDiscount.visible = shopCfg.Price < shopCfg.originalPrice; if (item.m_grpDiscount.visible) { EffectUI _effectUI = EffectUIPool.CreateEffectUI(item.m_holderfEff, "ui_Small_parts", "store_Value"); _effectUIs.Add(_effectUI); item.m_holderfEff.visible = shopCfg.Price < shopCfg.originalPrice; } item.m_txtDesc.text = shopCfg.Price <= 0 ? "" : ShopDataManager.Instance.GetShopGoodsDiscount(shopCfg.id).ToString(); item.m_txtEndTime.SetVar("value", ShopDataManager.Instance.GetEndTime(shopCfg.id)).FlushVars(); item.m_txtEndTime.visible = shopCfg.endTime != ""; item.m_c2.selectedIndex = ShopDataManager.Instance.GetShopGoodsStateById(shopCfg.id) ? 1 : 0; item.m_txtLock.text = ShopDataManager.Instance.GetShopGoodsStateTips(shopCfg.id); int buyNum = ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id); item.m_txtLimit.visible = shopCfg.maxBuyNum > 0; item.m_txtLimit.text = string.Format("{0}({1}/{2})", ShopDataManager.Instance.refreshType[shopCfg.refreshType], StringUtil.GetColorText(buyNum.ToString(), "#5A3E16"), shopCfg.maxBuyNum); item.m_c1.selectedIndex = shopCfg.maxBuyNum == 0 || buyNum < shopCfg.maxBuyNum ? 0 : 1; if (item.m_c1.selectedIndex == 0)//可购买 { item.m_btnBuy.m_txtOriginalPrice.text = NumberUtil.ChangeNumberUnit(shopCfg.originalPrice); if (shopCfg.Price > 0 && shopCfg.CostTypeReal != CostType.FREE)//不免费 { item.m_btnBuy.m_grpOriginalPrice.visible = shopCfg.originalPrice > 0 && shopCfg.originalPrice != shopCfg.Price; item.m_btnBuy.m_loaIcon.visible = true; item.m_btnBuy.m_txtPrice.text = NumberUtil.ChangeNumberUnit(shopCfg.Price);// cfg.price.ToString(); if (shopCfg.CostTypeReal == CostType.RMB)//人民币 { item.m_btnBuy.m_loaIcon.visible = false; item.m_btnBuy.m_txtIcon.visible = true; item.m_btnBuy.m_txtIcon.text = "¥"; } else//道具 { ItemCfg costItemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.CostIdReal); item.m_btnBuy.m_loaIcon.url = ResPathUtil.GetIconPath(costItemCfg); item.m_btnBuy.m_loaIcon.visible = true; item.m_btnBuy.m_txtIcon.visible = false; } } else { item.m_btnBuy.m_txtIcon.text = ""; item.m_btnBuy.m_loaIcon.visible = false; item.m_btnBuy.m_grpOriginalPrice.visible = false; item.m_btnBuy.m_txtPrice.text = "免费"; } } if (item.target.data == null) { item.target.onClick.Add(OnBtnBugItem); } item.target.data = shopCfg; bool isRed = item.m_c1.selectedIndex == 0 && item.m_c2.selectedIndex == 0 && shopCfg.Price == 0; RedDotController.Instance.SetComRedDot(item.target, isRed, "", -6, 100); UI_ListShopItem.ProxyEnd(); } public void OnBtnBugItem(EventContext context) { ShopCfg cfg = (context.sender as GObject).data as ShopCfg; bool isSellOut = cfg.maxBuyNum > 0 && cfg.maxBuyNum - ShopDataManager.Instance.GetGoodsBuyNumById(cfg.id) <= 0; if (isSellOut) { PromptController.Instance.ShowFloatTextPrompt("已售罄"); return; } // if (!ShopDataManager.Instance.GetShopGoodsStateById(cfg.id)) // { // PromptController.Instance.ShowFloatTextPrompt(ShopDataManager.Instance.GetShopGoodsStateTips(cfg.id)); // return; // } if (cfg.CostTypeReal == CostType.FREE) { ShopSProxy.ReqShopBuy(cfg.id, 1).Coroutine(); LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2); } else { ViewManager.Show(cfg.id); } } } }