ShopSProxy.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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.UpdateGiftData(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)
  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.UpdateGiftData(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.GIFT_BAG && itemCfg.subType == ConstItemSubType.GIFT_BAG_AUTO)
  41. {
  42. itemDatas = ItemUtil.CreateItemDataList(itemCfg.itemsArr, response.Times * shopCfg.itemNum);
  43. }
  44. else
  45. {
  46. itemDatas = ItemUtil.CreateItemDataList(itemCfg.id, response.Times * shopCfg.itemNum);
  47. }
  48. BonusController.TryShowBonusList(itemDatas);
  49. EventAgent.DispatchEvent(ConstMessage.SHOP_BUY);
  50. return true;
  51. }
  52. }
  53. return false;
  54. }
  55. //领取VIP等级礼包
  56. public static async ETTask<bool> ReqGetVipGiftBag(int vipLv)
  57. {
  58. S2C_GetVipLevelGift response = null;
  59. response = (S2C_GetVipLevelGift)await MessageHelper.SendToServer(new C2S_GetVipLevelGift() { VipLevel = vipLv });
  60. if (response != null)
  61. {
  62. if (response.Error == ErrorCode.ERR_Success)
  63. {
  64. return true;
  65. }
  66. }
  67. return false;
  68. }
  69. //领取VIP周礼包
  70. public static async ETTask<bool> ReqGetVipWeekGiftBag(int vipLv)
  71. {
  72. S2C_GetVipWeekGift response = null;
  73. response = (S2C_GetVipWeekGift)await MessageHelper.SendToServer(new C2S_GetVipWeekGift() { VipLevel = vipLv });
  74. if (response != null)
  75. {
  76. if (response.Error == ErrorCode.ERR_Success)
  77. {
  78. return true;
  79. }
  80. }
  81. return false;
  82. }
  83. }
  84. }