LuckyBoxSProxy.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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()
  33. { LuckyBoxId = luckyBoxId, Times = times, Free = free, ActivityId = activityId });
  34. if (response != null)
  35. {
  36. if (response.Error == ErrorCode.ERR_Success)
  37. {
  38. ActivityOpenCfg activityOpenCfg = ActivityOpenCfgArray.Instance.GetCfg(response.ActivityId);
  39. if (activityOpenCfg != null && activityOpenCfg.paramsArr[0] == luckyBoxId)
  40. {
  41. var activityCfg = ActivityOpenCfgArray.Instance.GetCfg(response.ActivityId);
  42. if (activityCfg.type == ConstLimitTimeActivityType.ActLimitLuckyBox)
  43. ActivityDataManager.Instance.allPlayTimes += response.Times;
  44. else if (activityCfg.type == ConstLimitTimeActivityType.ActLimitTsy)
  45. ActivityDataManager.Instance.allTsyPlayTimes += response.Times;
  46. else if (activityCfg.type == ConstLimitTimeActivityType.ActLimitStlyc)
  47. {
  48. if (ActivityDataManager.Instance.allLimitStlycTimes < 20 &&
  49. (ActivityDataManager.Instance.allLimitStlycTimes + response.Times) >= 20)
  50. {
  51. LuckyBoxDataManager.Instance.OPEN_LUCKY_DISCONT = true;
  52. }
  53. ActivityDataManager.Instance.allLimitStlycTimes += response.Times;
  54. }
  55. }
  56. LuckyBoxDataManager.Instance.UpdatePlayTimes(response.LuckyBoxId, response.Times);
  57. // LuckyBoxDataManager.Instance.luckyBoxIndex = response.LuckyBoxId;
  58. LuckyBoxDataManager.Instance.RewardList = ItemUtil.CreateItemDataList(response.bonusList);
  59. return true;
  60. }
  61. }
  62. return false;
  63. }
  64. //请求轮换抽奖活动信息
  65. public static async ETTask<int> ReqGetLuckyBoxRotatingInfo()
  66. {
  67. S2C_GetLuckyBoxRotatingInfo response = null;
  68. response = (S2C_GetLuckyBoxRotatingInfo)await MessageHelper.SendToServer(new C2S_GetLuckyBoxRotatingInfo()
  69. { });
  70. if (response != null)
  71. {
  72. if (response.Error == ErrorCode.ERR_Success)
  73. {
  74. LuckyBoxDataManager.Instance.RotatingId = response.RotatingId;
  75. return response.RotatingId;
  76. }
  77. }
  78. return 0;
  79. }
  80. //请求抽奖初始信息
  81. public static async ETTask ReqGetLuckyBoxInfo()
  82. {
  83. S2C_GetLuckyBoxInfo response = null;
  84. response = (S2C_GetLuckyBoxInfo)await MessageHelper.SendToServer(new C2S_GetLuckyBoxInfo() { });
  85. if (response != null)
  86. {
  87. if (response.Error == ErrorCode.ERR_Success)
  88. {
  89. LuckyBoxDataManager.Instance.InitServerData(response);
  90. }
  91. }
  92. }
  93. //许愿池许愿记录
  94. public static async ETTask<bool> ReqAddWishingPoolInfo(int suitId, int activityId)
  95. {
  96. S2C_AddWishingPoolInfo response = null;
  97. response = (S2C_AddWishingPoolInfo)await MessageHelper.SendToServer(new C2S_AddWishingPoolInfo()
  98. { SuitId = suitId, ActivityId = activityId });
  99. if (response != null)
  100. {
  101. if (response.Error == ErrorCode.ERR_Success)
  102. {
  103. int index = LuckyBoxDataManager.Instance.KsActivityId.IndexOf(response.ActivityId);
  104. LuckyBoxDataManager.Instance.VsStatus[index] = response.Status;
  105. return true;
  106. }
  107. }
  108. return false;
  109. }
  110. ////获取许愿池许愿记录
  111. public static async ETTask<bool> ReqGetWishingPoolInfo()
  112. {
  113. S2C_GetWishingPoolInfo response = null;
  114. response = (S2C_GetWishingPoolInfo)await MessageHelper.SendToServer(new C2S_GetWishingPoolInfo() { });
  115. if (response != null)
  116. {
  117. if (response.Error == ErrorCode.ERR_Success)
  118. {
  119. LuckyBoxDataManager.Instance.KsActivityId = response.KsActivityId;
  120. LuckyBoxDataManager.Instance.VsStatus = response.VsStatus;
  121. return true;
  122. }
  123. }
  124. return false;
  125. }
  126. ////抽奖盲盒
  127. public static async ETTask<bool> ReqGetBlindBox(int id, int times)
  128. {
  129. M2C_BlindBox response = null;
  130. int activtyId = ActivityDataManager.Instance.GetCurOpenActiveByType(102);
  131. response = (M2C_BlindBox)await MessageHelper.SendToServer(new C2M_BlindBox()
  132. { BlindBoxId = id, Times = times, ActivityId = activtyId });
  133. if (response != null)
  134. {
  135. if (response.Error == ErrorCode.ERR_Success)
  136. {
  137. LuckyBoxDataManager.Instance.BlindBoxReward = response.bonusList;
  138. return true;
  139. }
  140. //ErrorCodeController.Handler(response.Error);
  141. }
  142. else
  143. {
  144. ErrorCodeController.Handler(ErrorCode.ERR_NetWorkError);
  145. }
  146. return false;
  147. }
  148. }
  149. }