ShopViewManager.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. using System;
  2. using System.Collections.Generic;
  3. using ET;
  4. using FairyGUI;
  5. using UI.Store;
  6. namespace GFGGame
  7. {
  8. public class ShopViewManager : SingletonBase<ShopViewManager>
  9. {
  10. public void BuyItem(int itemId, int itemCount, int shopType, ShopCfg shopCfg)
  11. {
  12. BuyItemConteoller.Show(itemId, itemCount, ConstBuyType.TYPE_SHOP, shopType, () =>
  13. {
  14. LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.FU_ZHUANG_DIAN, 2);
  15. GetSuitItemController.TryShow(0);
  16. }, true, false, GameConst.MAX_COUNT_TO_BUY_ITEMS);
  17. }
  18. //更行vip进度
  19. public void UpdateVipProgressCom(GObject obj)
  20. {
  21. UI_ComVipLv com = UI_ComVipLv.Proxy(obj);
  22. com.m_txtLv.text = RoleDataManager.vipLv.ToString();
  23. VipCfg vipCfg = VipCfgArray.Instance.GetCfg(RoleDataManager.vipLv);
  24. VipCfg nextVipCfg = VipCfgArray.Instance.GetCfg(RoleDataManager.vipLv + 1);
  25. com.m_txtTipsFull.visible = nextVipCfg == null;
  26. if (com.m_btnRule.data == null)
  27. {
  28. com.m_btnRule.onClick.Add(RuleController.ShowRuleView);
  29. com.m_btnRule.data = 300009;
  30. }
  31. if (nextVipCfg != null)
  32. {
  33. com.m_proExp.target.max = vipCfg.num;
  34. com.m_proExp.target.value = RoleDataManager.vipExp;
  35. com.m_proExp.m_txttitle.SetVar("value", com.m_proExp.target.value.ToString()).FlushVars();
  36. com.m_proExp.m_txttitle.SetVar("max", com.m_proExp.target.max.ToString()).FlushVars();
  37. com.m_txtTips.SetVar("exp", (vipCfg.num - RoleDataManager.vipExp).ToString()).FlushVars();
  38. com.m_txtTips.SetVar("vipLv", (nextVipCfg.id).ToString()).FlushVars();
  39. }
  40. UI_ComVipLv.ProxyEnd();
  41. }
  42. //更新商品item
  43. public void UptadeItem(GObject obj, ShopCfg shopCfg)
  44. {
  45. UI_ListShopItem item = UI_ListShopItem.Proxy(obj);
  46. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId);
  47. item.m_txtName.text = shopCfg.itemName;
  48. item.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
  49. item.m_grpDiscount.visible = shopCfg.price < shopCfg.originalPrice;
  50. item.m_txtDesc.text = ((double)(shopCfg.originalPrice / shopCfg.price) * 100).ToString();
  51. item.m_txtEndTime.SetVar("value", ShopDataManager.Instance.GetEndTime(shopCfg.id)).FlushVars();
  52. item.m_txtEndTime.visible = shopCfg.endTime != "";
  53. item.m_c2.selectedIndex = ShopDataManager.Instance.GetShopGoodsStateById(shopCfg.id) ? 0 : 1;
  54. if (shopCfg.lockType == LockType.STORY_LV)
  55. {
  56. StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(shopCfg.storyLevelId);
  57. item.m_txtLock.text = string.Format("通关{0}-{1}解锁", StoryUtil.GetChapterOrder(storyLevelCfg.chapterId), storyLevelCfg.order);
  58. }
  59. else if (shopCfg.lockType == LockType.ROLE_LV)
  60. {
  61. item.m_txtLock.text = string.Format("角色达到{0}级解锁", shopCfg.lv);
  62. }
  63. else if (shopCfg.lockType == LockType.MONTH_CARD_TYPE)
  64. {
  65. item.m_txtLock.text = string.Format("开通{0}解锁", shopCfg.MonthlyCardType == MonthCardType.Gold ? "金卡" : "黑金卡");
  66. }
  67. int buyNum = ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id);
  68. item.m_txtLimit.visible = shopCfg.maxBuyNum > 0;
  69. item.m_txtLimit.text = string.Format("{0}({1}/{2})", ShopDataManager.Instance.refreshType[shopCfg.refreshType], StringUtil.GetColorText(buyNum.ToString(), "#5A3E16"), shopCfg.maxBuyNum);
  70. item.m_c1.selectedIndex = shopCfg.maxBuyNum == 0 || buyNum < shopCfg.maxBuyNum ? 0 : 1;
  71. if (item.m_c1.selectedIndex == 0)//可购买
  72. {
  73. item.m_btnBuy.m_txtOriginalPrice.text = NumberUtil.ChangeNumberUnit(shopCfg.originalPrice);
  74. if (shopCfg.price > 0 && shopCfg.costType != CostType.FREE)//不免费
  75. {
  76. item.m_btnBuy.m_grpOriginalPrice.visible = shopCfg.originalPrice > 0;
  77. item.m_btnBuy.m_loaIcon.visible = true;
  78. item.m_btnBuy.m_txtPrice.text = NumberUtil.ChangeNumberUnit(shopCfg.price);// cfg.price.ToString();
  79. if (shopCfg.costType == CostType.RMB)//人民币
  80. {
  81. item.m_btnBuy.m_loaIcon.visible = false;
  82. item.m_btnBuy.m_txtIcon.visible = true;
  83. item.m_btnBuy.m_txtIcon.text = "¥";
  84. }
  85. else//道具
  86. {
  87. ItemCfg costItemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.costId);
  88. item.m_btnBuy.m_loaIcon.url = ResPathUtil.GetCommonGameResPath(costItemCfg.res);
  89. item.m_btnBuy.m_loaIcon.visible = true;
  90. item.m_btnBuy.m_txtIcon.visible = false;
  91. }
  92. }
  93. else
  94. {
  95. item.m_btnBuy.m_txtIcon.text = "";
  96. item.m_btnBuy.m_loaIcon.visible = false;
  97. item.m_btnBuy.m_grpOriginalPrice.visible = false;
  98. item.m_btnBuy.m_txtPrice.text = "免费";
  99. }
  100. }
  101. if (item.target.data == null)
  102. {
  103. item.target.onClick.Add(OnBtnBuyClick);
  104. }
  105. item.target.data = shopCfg.id;
  106. bool isRed = item.m_c1.selectedIndex == 0 && item.m_c2.selectedIndex == 0 && shopCfg.price == 0;
  107. RedDotController.Instance.SetComRedDot(item.target, isRed, "", -6, 100);
  108. UI_ListShopItem.ProxyEnd();
  109. }
  110. private void OnBtnBuyClick(EventContext context)
  111. {
  112. GObject btn = context.sender as GObject;
  113. int giftId = (int)btn.data;
  114. ShopCfg cfg = ShopCfgArray.Instance.GetCfg(giftId);
  115. if (cfg.maxBuyNum != 0 && ShopDataManager.Instance.GetGoodsBuyNumById(giftId) == cfg.maxBuyNum)
  116. {
  117. PromptController.Instance.ShowFloatTextPrompt("已售罄");
  118. return;
  119. }
  120. if (cfg.price == 0 || cfg.costType == CostType.FREE)
  121. {
  122. RechargeSProxy.ReqBuyGiftBag((int)btn.data).Coroutine();
  123. }
  124. else
  125. {
  126. ViewManager.Show<GiftBagBuyView>(btn.data);
  127. }
  128. }
  129. }
  130. }