ShopSProxy.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System.Collections.Generic;
  2. using ET;
  3. namespace GFGGame
  4. {
  5. public class ShopSProxy
  6. {
  7. // public static async ETTask<bool> ShopBuy(int shopType, int buyId, long buyCount)
  8. // {
  9. // M2C_ShopBuy response = null;
  10. // response = (M2C_ShopBuy)await MessageHelper.SendToServer(new C2M_ShopBuy() { ShopType = shopType, BuyId = buyId, BuyCount = (int)buyCount });
  11. // if (response != null)
  12. // {
  13. // if (response.Error == ErrorCode.ERR_Success)
  14. // {
  15. // // EventAgent.DispatchEvent(ConstMessage.SHOP_BUY);
  16. // return true;
  17. // }
  18. // }
  19. // return false;
  20. // }
  21. public static async ETTask<bool> ReqShopInfo()
  22. {
  23. S2C_RequestShopInfo response = null;
  24. response = (S2C_RequestShopInfo)await MessageHelper.SendToServer(new C2S_RequestShopInfo());
  25. if (response != null)
  26. {
  27. if (response.Error == ErrorCode.ERR_Success)
  28. {
  29. for (int i = 0; i < response.ks.Count; i++)
  30. {
  31. ShopDataManager.Instance.UpdateGiftData(response.ks[i], response.vs[i]);
  32. }
  33. return true;
  34. }
  35. }
  36. return false;
  37. }
  38. public static async ETTask<bool> ReqShopBuy(int buyId, long buyCount)
  39. {
  40. S2C_ShopBuy response = null;
  41. response = (S2C_ShopBuy)await MessageHelper.SendToServer(new C2S_ShopBuy() { BuyId = buyId, Times = (int)buyCount });
  42. if (response != null)
  43. {
  44. if (response.Error == ErrorCode.ERR_Success)
  45. {
  46. ShopDataManager.Instance.UpdateGiftData(response.BuyId, response.TotalTimes);
  47. ShopCfg shopCfg = ShopCfgArray.Instance.GetCfg(response.BuyId);
  48. ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId);
  49. if (LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL && shopCfg.costType == CostType.RMB)
  50. {
  51. PromptController.Instance.ShowFloatTextPrompt("虚拟充值成功");
  52. }
  53. List<ItemData> itemDatas;
  54. if (itemCfg.itemType == ConstItemType.GIFT_BAG)
  55. {
  56. itemDatas = ItemUtil.CreateItemDataList(itemCfg.itemsArr, response.Times * shopCfg.itemNum);
  57. }
  58. else
  59. {
  60. itemDatas = ItemUtil.CreateItemDataList(itemCfg.id, response.Times * shopCfg.itemNum);
  61. }
  62. BonusController.TryShowBonusList(itemDatas);
  63. return true;
  64. }
  65. }
  66. return false;
  67. }
  68. }
  69. }