ShopSProxy.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using System.Collections.Generic;
  2. using ET;
  3. namespace GFGGame
  4. {
  5. public class ShopSProxy
  6. {
  7. public static async ETTask<bool> ReqShopInfo()
  8. {
  9. S2C_RequestShopInfo response = null;
  10. response = (S2C_RequestShopInfo)await MessageHelper.SendToServer(new C2S_RequestShopInfo());
  11. if (response != null)
  12. {
  13. if (response.Error == ErrorCode.ERR_Success)
  14. {
  15. for (int i = 0; i < response.ks.Count; i++)
  16. {
  17. ShopDataManager.Instance.UpdateGoodsData(response.ks[i], response.vs[i]);
  18. }
  19. return true;
  20. }
  21. }
  22. return false;
  23. }
  24. public static async ETTask<bool> ReqShopBuy(int buyId, long buyCount = 1)
  25. {
  26. S2C_ShopBuy response = null;
  27. response = (S2C_ShopBuy)await MessageHelper.SendToServer(new C2S_ShopBuy() { BuyId = buyId, Times = (int)buyCount });
  28. if (response != null)
  29. {
  30. if (response.Error == ErrorCode.ERR_Success)
  31. {
  32. ShopDataManager.Instance.UpdateGoodsData(response.BuyId, response.TotalTimes);
  33. ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(response.BuyId);
  34. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId);
  35. if (LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL && shopCfg.costType == CostType.RMB)
  36. {
  37. PromptController.Instance.ShowFloatTextPrompt("虚拟充值成功");
  38. }
  39. List<ItemData> itemDatas;
  40. if (itemCfg.itemType == ConstItemType.USEABLE &&
  41. (itemCfg.subType == ConstItemSubType.USEABLE_AUTO))
  42. {
  43. itemDatas = ItemUtil.CreateItemDataList(itemCfg.itemsArr, response.Times * shopCfg.itemNum);
  44. }
  45. else
  46. {
  47. itemDatas = ItemUtil.CreateItemDataList(itemCfg.id, response.Times * shopCfg.itemNum);
  48. }
  49. EventAgent.DispatchEvent(ConstMessage.CONTINUOUS_REBATE_GIFT_SHOP_BUY, shopCfg);
  50. BonusController.TryShowBonusList(itemDatas);
  51. EventAgent.DispatchEvent(ConstMessage.SHOP_BUY);
  52. return true;
  53. }
  54. }
  55. return false;
  56. }
  57. /**********************************************会员中心**********************************************/
  58. //领取VIP等级礼包
  59. public static async ETTask<bool> ReqGetVipGiftBag(int vipLv)
  60. {
  61. S2C_GetVipLevelGift response = null;
  62. response = (S2C_GetVipLevelGift)await MessageHelper.SendToServer(new C2S_GetVipLevelGift() { VipLevel = vipLv });
  63. if (response != null)
  64. {
  65. if (response.Error == ErrorCode.ERR_Success)
  66. {
  67. int[][] bonus = VipCfgArray.Instance.GetCfg(vipLv).bonusOnceArr;
  68. BonusController.TryShowBonusList(bonus);
  69. return true;
  70. }
  71. }
  72. return false;
  73. }
  74. //领取VIP周礼包
  75. public static async ETTask<bool> ReqGetVipWeekGiftBag(int vipLv)
  76. {
  77. S2C_GetVipWeekGift response = null;
  78. response = (S2C_GetVipWeekGift)await MessageHelper.SendToServer(new C2S_GetVipWeekGift() { VipLevel = vipLv });
  79. if (response != null)
  80. {
  81. if (response.Error == ErrorCode.ERR_Success)
  82. {
  83. int[][] bonus = VipCfgArray.Instance.GetCfg(vipLv).bonusWeekArr;
  84. BonusController.TryShowBonusList(bonus);
  85. return true;
  86. }
  87. }
  88. return false;
  89. }
  90. /*********************************************************月卡***************************************************/
  91. //领取每日返还珍珠
  92. public static async ETTask<bool> ReqGetMonthCardReward(int monthCardType)
  93. {
  94. S2C_GetMonthCardReward response = null;
  95. response = (S2C_GetMonthCardReward)await MessageHelper.SendToServer(new C2S_GetMonthCardReward() { MonthCardType = monthCardType });
  96. if (response != null)
  97. {
  98. if (response.Error == ErrorCode.ERR_Success)
  99. {
  100. return true;
  101. }
  102. }
  103. return false;
  104. }
  105. //领取专属单品
  106. public static async ETTask<bool> ReqGetMonthCardItem(int month)
  107. {
  108. S2C_GetMonthCardItem response = null;
  109. response = (S2C_GetMonthCardItem)await MessageHelper.SendToServer(new C2S_GetMonthCardItem());
  110. if (response != null)
  111. {
  112. if (response.Error == ErrorCode.ERR_Success)
  113. {
  114. MonthlyCardClothesCfg clothesCfg = MonthlyCardClothesCfgArray.Instance.GetCfgByyearAndmonth(TimeUtil.GetCurYear(), month);
  115. List<ItemData> itemDatas = ItemUtil.CreateItemDataList(clothesCfg.clothesArr[0], clothesCfg.clothesArr[1]);
  116. BonusController.TryShowBonusList(itemDatas);
  117. return true;
  118. }
  119. }
  120. return false;
  121. }
  122. }
  123. }