LuckyBoxSProxy.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. using cfg.GfgCfg;
  2. using ET;
  3. using GFGGame;
  4. namespace ET
  5. {
  6. public class S2C_NoticeLuckyBoxFreeTimeHandler : AMHandler<S2C_NoticeLuckyBoxFreeTime>
  7. {
  8. protected override async ETTask Run(Session session, S2C_NoticeLuckyBoxFreeTime message)
  9. {
  10. LuckyBoxDataManager.Instance.UpdateFreeTime(message.LuckyBoxId, message.FreeTime);
  11. await ETTask.CompletedTask;
  12. }
  13. }
  14. //活动开启服务端推送最新许愿记录
  15. public class S2C_PushWishingPoolInfoHandler : AMHandler<S2C_PushWishingPoolInfo>
  16. {
  17. protected override async ETTask Run(Session session, S2C_PushWishingPoolInfo message)
  18. {
  19. LuckyBoxDataManager.Instance.KsActivityId = message.KsActivityId;
  20. LuckyBoxDataManager.Instance.VsStatus = message.VsStatus;
  21. await ETTask.CompletedTask;
  22. }
  23. }
  24. }
  25. namespace GFGGame
  26. {
  27. public class LuckyBoxSProxy
  28. {
  29. //抽奖
  30. public static async ETTask<bool> ReqGetBonus(int luckyBoxId, int times, bool free = false, int activityId = 0)
  31. {
  32. M2C_DrawLuckyBox response = null;
  33. response = (M2C_DrawLuckyBox)await MessageHelper.SendToServer(new C2M_DrawLuckyBox()
  34. { LuckyBoxId = luckyBoxId, Times = times, Free = free, ActivityId = activityId });
  35. if (response != null)
  36. {
  37. if (response.Error == ErrorCode.ERR_Success)
  38. {
  39. ActivityOpenCfg activityOpenCfg =
  40. CommonDataManager.Tables.TblActivityOpenCfg.GetOrDefault(response.ActivityId);
  41. if (activityOpenCfg != null && activityOpenCfg.Params1[0] == luckyBoxId)
  42. {
  43. var activityCfg = CommonDataManager.Tables.TblActivityOpenCfg.GetOrDefault(response.ActivityId);
  44. if (activityCfg.Type == ConstLimitTimeActivityType.ActLimitLuckyBox)
  45. ActivityDataManager.Instance.allPlayTimes += response.Times;
  46. else if (activityCfg.Type == ConstLimitTimeActivityType.ActLimitTsy)
  47. ActivityDataManager.Instance.allTsyPlayTimes += response.Times;
  48. else if (activityCfg.Type == ConstLimitTimeActivityType.ActLimitStlyc)
  49. {
  50. if (ActivityDataManager.Instance.allLimitStlycTimes < 20 &&
  51. (ActivityDataManager.Instance.allLimitStlycTimes + response.Times) >= 20)
  52. {
  53. LuckyBoxDataManager.Instance.OPEN_LUCKY_DISCONT = true;
  54. }
  55. ActivityDataManager.Instance.allLimitStlycTimes += response.Times;
  56. }
  57. }
  58. LuckyBoxDataManager.Instance.UpdatePlayTimes(response.LuckyBoxId, response.Times);
  59. // LuckyBoxDataManager.Instance.luckyBoxIndex = response.LuckyBoxId;
  60. LuckyBoxDataManager.Instance.RewardList = ItemUtil.CreateItemDataList(response.bonusList);
  61. return true;
  62. }
  63. }
  64. return false;
  65. }
  66. //请求轮换抽奖活动信息
  67. public static async ETTask<int> ReqGetLuckyBoxRotatingInfo()
  68. {
  69. S2C_GetLuckyBoxRotatingInfo response = null;
  70. response = (S2C_GetLuckyBoxRotatingInfo)await MessageHelper.SendToServer(new C2S_GetLuckyBoxRotatingInfo()
  71. { });
  72. if (response != null)
  73. {
  74. if (response.Error == ErrorCode.ERR_Success)
  75. {
  76. LuckyBoxDataManager.Instance.RotatingId = response.RotatingId;
  77. return response.RotatingId;
  78. }
  79. }
  80. return 0;
  81. }
  82. //请求抽奖初始信息
  83. public static async ETTask ReqGetLuckyBoxInfo()
  84. {
  85. S2C_GetLuckyBoxInfo response = null;
  86. response = (S2C_GetLuckyBoxInfo)await MessageHelper.SendToServer(new C2S_GetLuckyBoxInfo() { });
  87. if (response != null)
  88. {
  89. if (response.Error == ErrorCode.ERR_Success)
  90. {
  91. LuckyBoxDataManager.Instance.InitServerData(response);
  92. }
  93. }
  94. }
  95. //许愿池许愿记录
  96. public static async ETTask<bool> ReqAddWishingPoolInfo(int suitId, int activityId)
  97. {
  98. S2C_AddWishingPoolInfo response = null;
  99. response = (S2C_AddWishingPoolInfo)await MessageHelper.SendToServer(new C2S_AddWishingPoolInfo()
  100. { SuitId = suitId, ActivityId = activityId });
  101. if (response != null)
  102. {
  103. if (response.Error == ErrorCode.ERR_Success)
  104. {
  105. int index = LuckyBoxDataManager.Instance.KsActivityId.IndexOf(response.ActivityId);
  106. LuckyBoxDataManager.Instance.VsStatus[index] = response.Status;
  107. return true;
  108. }
  109. }
  110. return false;
  111. }
  112. ////获取许愿池许愿记录
  113. public static async ETTask<bool> ReqGetWishingPoolInfo()
  114. {
  115. S2C_GetWishingPoolInfo response = null;
  116. response = (S2C_GetWishingPoolInfo)await MessageHelper.SendToServer(new C2S_GetWishingPoolInfo() { });
  117. if (response != null)
  118. {
  119. if (response.Error == ErrorCode.ERR_Success)
  120. {
  121. LuckyBoxDataManager.Instance.KsActivityId = response.KsActivityId;
  122. LuckyBoxDataManager.Instance.VsStatus = response.VsStatus;
  123. return true;
  124. }
  125. }
  126. return false;
  127. }
  128. ////抽奖盲盒
  129. public static async ETTask<bool> ReqGetBlindBox(int id, int times)
  130. {
  131. M2C_BlindBox response = null;
  132. int activtyId = ActivityDataManager.Instance.GetCurOpenActiveByType(102);
  133. response = (M2C_BlindBox)await MessageHelper.SendToServer(new C2M_BlindBox()
  134. { BlindBoxId = id, Times = times, ActivityId = activtyId });
  135. if (response != null)
  136. {
  137. if (response.Error == ErrorCode.ERR_Success)
  138. {
  139. LuckyBoxDataManager.Instance.BlindBoxReward = response.bonusList;
  140. return true;
  141. }
  142. //ErrorCodeController.Handler(response.Error);
  143. }
  144. else
  145. {
  146. ErrorCodeController.Handler(ErrorCode.ERR_NetWorkError);
  147. }
  148. return false;
  149. }
  150. }
  151. }