LuckyBoxSProxy.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using ET;
  2. using GFGGame;
  3. namespace ET
  4. {
  5. public class S2C_NoticeLuckyBoxFreeTimeHandler : AMHandler<S2C_NoticeLuckyBoxFreeTime>
  6. {
  7. protected override async ETTask Run(Session session, S2C_NoticeLuckyBoxFreeTime message)
  8. {
  9. LuckyBoxDataManager.Instance.UpdateFreeTime(message.LuckyBoxId, message.FreeTime);
  10. await ETTask.CompletedTask;
  11. }
  12. }
  13. //活动开启服务端推送最新许愿记录
  14. public class S2C_PushWishingPoolInfoHandler : AMHandler<S2C_PushWishingPoolInfo>
  15. {
  16. protected override async ETTask Run(Session session, S2C_PushWishingPoolInfo message)
  17. {
  18. LuckyBoxDataManager.Instance.KsActivityId = message.KsActivityId;
  19. LuckyBoxDataManager.Instance.VsStatus = message.VsStatus;
  20. await ETTask.CompletedTask;
  21. }
  22. }
  23. }
  24. namespace GFGGame
  25. {
  26. public class LuckyBoxSProxy
  27. {
  28. //抽奖
  29. public static async ETTask<bool> ReqGetBonus(int luckyBoxId, int times, bool free = false)
  30. {
  31. M2C_DrawLuckyBox response = null;
  32. response = (M2C_DrawLuckyBox)await MessageHelper.SendToServer(new C2M_DrawLuckyBox() { LuckyBoxId = luckyBoxId, Times = times, Free = free });
  33. if (response != null)
  34. {
  35. if (response.Error == ErrorCode.ERR_Success)
  36. {
  37. ActivityOpenCfg activityOpenCfg = ActivityOpenCfgArray.Instance.GetCfg(ActivityDataManager.Instance.actLuckyBoxId);
  38. if (activityOpenCfg != null && activityOpenCfg.paramsArr[0] == luckyBoxId)
  39. {
  40. ActivityDataManager.Instance.allPlayTimes += response.Times;
  41. }
  42. LuckyBoxDataManager.Instance.times = response.Times;
  43. // LuckyBoxDataManager.Instance.luckyBoxIndex = response.LuckyBoxId;
  44. LuckyBoxDataManager.Instance.RewardList = ItemUtil.CreateItemDataList(response.bonusList);
  45. return true;
  46. }
  47. }
  48. return false;
  49. }
  50. //请求轮换抽奖活动信息
  51. public static async ETTask<int> ReqGetLuckyBoxRotatingInfo()
  52. {
  53. S2C_GetLuckyBoxRotatingInfo response = null;
  54. response = (S2C_GetLuckyBoxRotatingInfo)await MessageHelper.SendToServer(new C2S_GetLuckyBoxRotatingInfo() { });
  55. if (response != null)
  56. {
  57. if (response.Error == ErrorCode.ERR_Success)
  58. {
  59. LuckyBoxDataManager.Instance.RotatingId = response.RotatingId;
  60. return response.RotatingId;
  61. }
  62. }
  63. return 0;
  64. }
  65. //请求抽奖初始信息
  66. public static async ETTask ReqGetLuckyBoxInfo()
  67. {
  68. S2C_GetLuckyBoxInfo response = null;
  69. response = (S2C_GetLuckyBoxInfo)await MessageHelper.SendToServer(new C2S_GetLuckyBoxInfo() { });
  70. if(response != null)
  71. {
  72. if (response.Error == ErrorCode.ERR_Success)
  73. {
  74. LuckyBoxDataManager.Instance.InitServerData(response);
  75. }
  76. }
  77. }
  78. //许愿池许愿记录
  79. public static async ETTask<bool> ReqAddWishingPoolInfo(int suitId,int activityId)
  80. {
  81. S2C_AddWishingPoolInfo response = null;
  82. response = (S2C_AddWishingPoolInfo)await MessageHelper.SendToServer(new C2S_AddWishingPoolInfo() { SuitId = suitId , ActivityId = activityId });
  83. if (response != null)
  84. {
  85. if (response.Error == ErrorCode.ERR_Success)
  86. {
  87. int index = LuckyBoxDataManager.Instance.KsActivityId.IndexOf(response.ActivityId);
  88. LuckyBoxDataManager.Instance.VsStatus[index] = response.Status;
  89. return true;
  90. }
  91. }
  92. return false;
  93. }
  94. ////获取许愿池许愿记录
  95. public static async ETTask<bool> ReqGetWishingPoolInfo()
  96. {
  97. S2C_GetWishingPoolInfo response = null;
  98. response = (S2C_GetWishingPoolInfo)await MessageHelper.SendToServer(new C2S_GetWishingPoolInfo() { });
  99. if (response != null)
  100. {
  101. if (response.Error == ErrorCode.ERR_Success)
  102. {
  103. LuckyBoxDataManager.Instance.KsActivityId = response.KsActivityId;
  104. LuckyBoxDataManager.Instance.VsStatus = response.VsStatus;
  105. return true;
  106. }
  107. }
  108. return false;
  109. }
  110. }
  111. }