123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- using System;
- using System.Collections.Generic;
- using ET;
- using FairyGUI;
- using UI.Store;
- namespace GFGGame
- {
- public class ShopViewManager : SingletonBase<ShopViewManager>
- {
- 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();
- VipCfg vipCfg = VipCfgArray.Instance.GetCfg(RoleDataManager.vipLv);
- VipCfg nextVipCfg = VipCfgArray.Instance.GetCfg(RoleDataManager.vipLv + 1);
- com.m_txtTipsFull.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();
- }
- UI_ComVipLv.ProxyEnd();
- }
- //更新商品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;
- 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.costType != 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.costType == 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.costId);
- item.m_btnBuy.m_loaIcon.url = ResPathUtil.GetCommonGameResPath(costItemCfg.res);
- 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();
- }
- private 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.costType == CostType.RMB)
- // {
- // if (!AntiAddictionController.CheckAntiAddictionRecharge(cfg.price))
- // {
- // ShopSProxy.ReqShopBuy(cfg.id, 1).Coroutine();
- // LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
- // }
- // }
- // else
- if (cfg.costType == CostType.FREE)
- {
- ShopSProxy.ReqShopBuy(cfg.id, 1).Coroutine();
- LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
- }
- else
- {
- ViewManager.Show<ItemExchangeView>(cfg.id);
- }
- }
- }
- }
|