LuckyBoxSProxy.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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,int activityId = 0)
  30. {
  31. M2C_DrawLuckyBox response = null;
  32. response = (M2C_DrawLuckyBox)await MessageHelper.SendToServer(new C2M_DrawLuckyBox() { LuckyBoxId = luckyBoxId, Times = times, Free = free, ActivityId = activityId });
  33. if (response != null)
  34. {
  35. if (response.Error == ErrorCode.ERR_Success)
  36. {
  37. ActivityOpenCfg activityOpenCfg = ActivityOpenCfgArray.Instance.GetCfg(response.ActivityId);
  38. if (activityOpenCfg != null && activityOpenCfg.paramsArr[0] == luckyBoxId)
  39. {
  40. var activityCfg = ActivityOpenCfgArray.Instance.GetCfg(response.ActivityId);
  41. if (activityCfg.type == ConstLimitTimeActivityType.ActLimitLuckyBox)
  42. ActivityDataManager.Instance.allPlayTimes += response.Times;
  43. else if(activityCfg.type == ConstLimitTimeActivityType.ActLimitTsy)
  44. ActivityDataManager.Instance.allTsyPlayTimes += response.Times;
  45. }
  46. LuckyBoxDataManager.Instance.times = response.Times;
  47. // LuckyBoxDataManager.Instance.luckyBoxIndex = response.LuckyBoxId;
  48. LuckyBoxDataManager.Instance.RewardList = ItemUtil.CreateItemDataList(response.bonusList);
  49. return true;
  50. }
  51. }
  52. return false;
  53. }
  54. //请求轮换抽奖活动信息
  55. public static async ETTask<int> ReqGetLuckyBoxRotatingInfo()
  56. {
  57. S2C_GetLuckyBoxRotatingInfo response = null;
  58. response = (S2C_GetLuckyBoxRotatingInfo)await MessageHelper.SendToServer(new C2S_GetLuckyBoxRotatingInfo() { });
  59. if (response != null)
  60. {
  61. if (response.Error == ErrorCode.ERR_Success)
  62. {
  63. LuckyBoxDataManager.Instance.RotatingId = response.RotatingId;
  64. return response.RotatingId;
  65. }
  66. }
  67. return 0;
  68. }
  69. //请求抽奖初始信息
  70. public static async ETTask ReqGetLuckyBoxInfo()
  71. {
  72. S2C_GetLuckyBoxInfo response = null;
  73. response = (S2C_GetLuckyBoxInfo)await MessageHelper.SendToServer(new C2S_GetLuckyBoxInfo() { });
  74. if(response != null)
  75. {
  76. if (response.Error == ErrorCode.ERR_Success)
  77. {
  78. LuckyBoxDataManager.Instance.InitServerData(response);
  79. }
  80. }
  81. }
  82. //许愿池许愿记录
  83. public static async ETTask<bool> ReqAddWishingPoolInfo(int suitId,int activityId)
  84. {
  85. S2C_AddWishingPoolInfo response = null;
  86. response = (S2C_AddWishingPoolInfo)await MessageHelper.SendToServer(new C2S_AddWishingPoolInfo() { SuitId = suitId , ActivityId = activityId });
  87. if (response != null)
  88. {
  89. if (response.Error == ErrorCode.ERR_Success)
  90. {
  91. int index = LuckyBoxDataManager.Instance.KsActivityId.IndexOf(response.ActivityId);
  92. LuckyBoxDataManager.Instance.VsStatus[index] = response.Status;
  93. return true;
  94. }
  95. }
  96. return false;
  97. }
  98. ////获取许愿池许愿记录
  99. public static async ETTask<bool> ReqGetWishingPoolInfo()
  100. {
  101. S2C_GetWishingPoolInfo response = null;
  102. response = (S2C_GetWishingPoolInfo)await MessageHelper.SendToServer(new C2S_GetWishingPoolInfo() { });
  103. if (response != null)
  104. {
  105. if (response.Error == ErrorCode.ERR_Success)
  106. {
  107. LuckyBoxDataManager.Instance.KsActivityId = response.KsActivityId;
  108. LuckyBoxDataManager.Instance.VsStatus = response.VsStatus;
  109. return true;
  110. }
  111. }
  112. return false;
  113. }
  114. }
  115. }