using System; using System.Collections.Generic; using cfg.GfgCfg; 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 = CommonDataManager.Tables.TblVipCfg.GetOrDefault(RoleDataManager.vipLv); if (vipCfg == null) return; VipCfg nextVipCfg = CommonDataManager.Tables.TblVipCfg.GetOrDefault(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 = CommonDataManager.Tables.TblItemCfg.GetOrDefault(shopCfg.ItemId); try { item.m_txtName.text = shopCfg.ItemName; item.m_icon.url = ResPathUtil.GetIconPath(itemCfg); } catch (Exception e) { Console.WriteLine(e); throw; } item.m_grpDiscount.visible = shopCfg.Price < shopCfg.OriginalPrice; if (item.m_grpDiscount.visible) { // 修改为异步加载特效 EffectUIPool.CreateEffectUI(item.m_holderfEff, "ui_Small_parts", "store_Value", onComplete: (effect) => { if (effect != null) { _effectUIs.Add(effect); } }); item.m_holderfEff.visible = shopCfg.Price < shopCfg.OriginalPrice; } else { item.m_holderfEff.visible = false; } 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); 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 = CommonDataManager.Tables.TblItemCfg.GetOrDefault(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); } } } }