ShopViewManager.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. using System;
  2. using System.Collections.Generic;
  3. using cfg.GfgCfg;
  4. using ET;
  5. using FairyGUI;
  6. using UI.Store;
  7. namespace GFGGame
  8. {
  9. public class ShopViewManager : SingletonBase<ShopViewManager>
  10. {
  11. public void BuyItem(int itemId, int itemCount, int buyType, ShopCfg shopCfg)
  12. {
  13. BuyItemConteoller.Show(itemId, itemCount, buyType, () =>
  14. {
  15. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.FU_ZHUANG_DIAN, 2);
  16. GetSuitItemController.TryShow(0);
  17. }, true, false, GameConst.MAX_COUNT_TO_BUY_ITEMS);
  18. }
  19. //更行vip进度
  20. public void UpdateVipProgressCom(GObject obj)
  21. {
  22. UI_ComVipLv com = UI_ComVipLv.Proxy(obj);
  23. com.m_txtLv.text = RoleDataManager.vipLv.ToString();
  24. int level = RoleDataManager.vipLv;
  25. ET.Log.Debug("vipLv:" + level);
  26. ET.Log.Debug("vipExp:" + RoleDataManager.vipExp);
  27. VipCfg vipCfg =CommonDataManager.Tables.TblVipCfg.GetOrDefault(RoleDataManager.vipLv);
  28. if (vipCfg == null) return;
  29. VipCfg nextVipCfg = CommonDataManager.Tables.TblVipCfg.GetOrDefault(RoleDataManager.vipLv + 1);
  30. com.m_grpTips.visible = nextVipCfg != null;
  31. if (com.m_btnRule.data == null)
  32. {
  33. com.m_btnRule.onClick.Add(RuleController.ShowRuleView);
  34. com.m_btnRule.data = 300009;
  35. }
  36. if (nextVipCfg != null)
  37. {
  38. com.m_proExp.target.max = vipCfg.Num;
  39. com.m_proExp.target.value = RoleDataManager.vipExp;
  40. com.m_proExp.m_txttitle.SetVar("value", com.m_proExp.target.value.ToString()).FlushVars();
  41. com.m_proExp.m_txttitle.SetVar("max", com.m_proExp.target.max.ToString()).FlushVars();
  42. com.m_txtTips.SetVar("exp", (vipCfg.Num - RoleDataManager.vipExp).ToString()).FlushVars();
  43. com.m_txtTips.SetVar("vipLv", (nextVipCfg.Id).ToString()).FlushVars();
  44. }
  45. else
  46. {
  47. com.m_proExp.target.max = vipCfg.Num;
  48. com.m_proExp.target.value = RoleDataManager.vipExp;
  49. com.m_proExp.m_txttitle.SetVar("value", com.m_proExp.target.value.ToString()).FlushVars();
  50. com.m_proExp.m_txttitle.SetVar("max", "MAX").FlushVars();
  51. }
  52. UI_ComVipLv.ProxyEnd();
  53. }
  54. private List<EffectUI> _effectUIs = new List<EffectUI>();
  55. //清除商品item的特效
  56. public void ClearItemEff()
  57. {
  58. for (int i = 0; i < _effectUIs.Count; i++)
  59. {
  60. EffectUIPool.Recycle(_effectUIs[i]);
  61. _effectUIs[i] = null;
  62. }
  63. _effectUIs.Clear();
  64. }
  65. //更新商品item
  66. public void UptadeItem(GObject obj, ShopCfg shopCfg)
  67. {
  68. UI_ListShopItem item = UI_ListShopItem.Proxy(obj);
  69. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(shopCfg.ItemId);
  70. try
  71. {
  72. item.m_txtName.text = shopCfg.ItemName;
  73. item.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
  74. }
  75. catch (Exception e)
  76. {
  77. Console.WriteLine(e);
  78. throw;
  79. }
  80. item.m_grpDiscount.visible = shopCfg.Price < shopCfg.OriginalPrice;
  81. if (item.m_grpDiscount.visible)
  82. {
  83. EffectUI _effectUI = EffectUIPool.CreateEffectUI(item.m_holderfEff, "ui_Small_parts", "store_Value");
  84. _effectUIs.Add(_effectUI);
  85. item.m_holderfEff.visible = shopCfg.Price < shopCfg.OriginalPrice;
  86. }
  87. item.m_txtDesc.text = shopCfg.Price <= 0 ? "" : ShopDataManager.Instance.GetShopGoodsDiscount(shopCfg.Id).ToString();
  88. item.m_txtEndTime.SetVar("value", ShopDataManager.Instance.GetEndTime(shopCfg.Id)).FlushVars();
  89. item.m_txtEndTime.visible = shopCfg.EndTime != "";
  90. item.m_c2.selectedIndex = ShopDataManager.Instance.GetShopGoodsStateById(shopCfg.Id) ? 1 : 0;
  91. item.m_txtLock.text = ShopDataManager.Instance.GetShopGoodsStateTips(shopCfg.Id);
  92. int buyNum = ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.Id);
  93. item.m_txtLimit.visible = shopCfg.MaxBuyNum > 0;
  94. item.m_txtLimit.text = string.Format("{0}({1}/{2})", ShopDataManager.Instance.refreshType[shopCfg.RefreshType], StringUtil.GetColorText(buyNum.ToString(), "#5A3E16"), shopCfg.MaxBuyNum);
  95. item.m_c1.selectedIndex = shopCfg.MaxBuyNum == 0 || buyNum < shopCfg.MaxBuyNum ? 0 : 1;
  96. if (item.m_c1.selectedIndex == 0)//可购买
  97. {
  98. item.m_btnBuy.m_txtOriginalPrice.text = NumberUtil.ChangeNumberUnit(shopCfg.OriginalPrice);
  99. if (shopCfg.Price > 0 && shopCfg.CostTypeReal != CostType.FREE)//不免费
  100. {
  101. item.m_btnBuy.m_grpOriginalPrice.visible = shopCfg.OriginalPrice > 0 && shopCfg.OriginalPrice != shopCfg.Price;
  102. item.m_btnBuy.m_loaIcon.visible = true;
  103. item.m_btnBuy.m_txtPrice.text = NumberUtil.ChangeNumberUnit(shopCfg.Price);// cfg.price.ToString();
  104. if (shopCfg.CostTypeReal == CostType.RMB)//人民币
  105. {
  106. item.m_btnBuy.m_loaIcon.visible = false;
  107. item.m_btnBuy.m_txtIcon.visible = true;
  108. item.m_btnBuy.m_txtIcon.text = "¥";
  109. }
  110. else//道具
  111. {
  112. ItemCfg costItemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(shopCfg.CostIdReal);
  113. item.m_btnBuy.m_loaIcon.url = ResPathUtil.GetIconPath(costItemCfg);
  114. item.m_btnBuy.m_loaIcon.visible = true;
  115. item.m_btnBuy.m_txtIcon.visible = false;
  116. }
  117. }
  118. else
  119. {
  120. item.m_btnBuy.m_txtIcon.text = "";
  121. item.m_btnBuy.m_loaIcon.visible = false;
  122. item.m_btnBuy.m_grpOriginalPrice.visible = false;
  123. item.m_btnBuy.m_txtPrice.text = "免费";
  124. }
  125. }
  126. if (item.target.data == null)
  127. {
  128. item.target.onClick.Add(OnBtnBugItem);
  129. }
  130. item.target.data = shopCfg;
  131. bool isRed = item.m_c1.selectedIndex == 0 && item.m_c2.selectedIndex == 0 && shopCfg.Price == 0;
  132. RedDotController.Instance.SetComRedDot(item.target, isRed, "", -6, 100);
  133. UI_ListShopItem.ProxyEnd();
  134. }
  135. public void OnBtnBugItem(EventContext context)
  136. {
  137. ShopCfg cfg = (context.sender as GObject).data as ShopCfg;
  138. bool isSellOut = cfg.MaxBuyNum > 0 && cfg.MaxBuyNum - ShopDataManager.Instance.GetGoodsBuyNumById(cfg.Id) <= 0;
  139. if (isSellOut)
  140. {
  141. PromptController.Instance.ShowFloatTextPrompt("已售罄");
  142. return;
  143. }
  144. // if (!ShopDataManager.Instance.GetShopGoodsStateById(cfg.id))
  145. // {
  146. // PromptController.Instance.ShowFloatTextPrompt(ShopDataManager.Instance.GetShopGoodsStateTips(cfg.id));
  147. // return;
  148. // }
  149. if (cfg.CostTypeReal == CostType.FREE)
  150. {
  151. ShopSProxy.ReqShopBuy(cfg.Id, 1).Coroutine();
  152. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
  153. }
  154. else
  155. {
  156. ViewManager.Show<ItemExchangeView>(cfg.Id);
  157. }
  158. }
  159. }
  160. }