LuckyBoxSProxy.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. else if (activityCfg.type == ConstLimitTimeActivityType.ActLimitStlyc)
  46. {
  47. if (ActivityDataManager.Instance.allLimitStlycTimes < 20 && (ActivityDataManager.Instance.allLimitStlycTimes + response.Times) >= 20)
  48. {
  49. LuckyBoxDataManager.Instance.OPEN_LUCKY_DISCONT = true;
  50. }
  51. ActivityDataManager.Instance.allLimitStlycTimes += response.Times;
  52. }
  53. }
  54. LuckyBoxDataManager.Instance.times = response.Times;
  55. // LuckyBoxDataManager.Instance.luckyBoxIndex = response.LuckyBoxId;
  56. LuckyBoxDataManager.Instance.RewardList = ItemUtil.CreateItemDataList(response.bonusList);
  57. return true;
  58. }
  59. }
  60. return false;
  61. }
  62. //请求轮换抽奖活动信息
  63. public static async ETTask<int> ReqGetLuckyBoxRotatingInfo()
  64. {
  65. S2C_GetLuckyBoxRotatingInfo response = null;
  66. response = (S2C_GetLuckyBoxRotatingInfo)await MessageHelper.SendToServer(new C2S_GetLuckyBoxRotatingInfo() { });
  67. if (response != null)
  68. {
  69. if (response.Error == ErrorCode.ERR_Success)
  70. {
  71. LuckyBoxDataManager.Instance.RotatingId = response.RotatingId;
  72. return response.RotatingId;
  73. }
  74. }
  75. return 0;
  76. }
  77. //请求抽奖初始信息
  78. public static async ETTask ReqGetLuckyBoxInfo()
  79. {
  80. S2C_GetLuckyBoxInfo response = null;
  81. response = (S2C_GetLuckyBoxInfo)await MessageHelper.SendToServer(new C2S_GetLuckyBoxInfo() { });
  82. if(response != null)
  83. {
  84. if (response.Error == ErrorCode.ERR_Success)
  85. {
  86. LuckyBoxDataManager.Instance.InitServerData(response);
  87. }
  88. }
  89. }
  90. //许愿池许愿记录
  91. public static async ETTask<bool> ReqAddWishingPoolInfo(int suitId,int activityId)
  92. {
  93. S2C_AddWishingPoolInfo response = null;
  94. response = (S2C_AddWishingPoolInfo)await MessageHelper.SendToServer(new C2S_AddWishingPoolInfo() { SuitId = suitId , ActivityId = activityId });
  95. if (response != null)
  96. {
  97. if (response.Error == ErrorCode.ERR_Success)
  98. {
  99. int index = LuckyBoxDataManager.Instance.KsActivityId.IndexOf(response.ActivityId);
  100. LuckyBoxDataManager.Instance.VsStatus[index] = response.Status;
  101. return true;
  102. }
  103. }
  104. return false;
  105. }
  106. ////获取许愿池许愿记录
  107. public static async ETTask<bool> ReqGetWishingPoolInfo()
  108. {
  109. S2C_GetWishingPoolInfo response = null;
  110. response = (S2C_GetWishingPoolInfo)await MessageHelper.SendToServer(new C2S_GetWishingPoolInfo() { });
  111. if (response != null)
  112. {
  113. if (response.Error == ErrorCode.ERR_Success)
  114. {
  115. LuckyBoxDataManager.Instance.KsActivityId = response.KsActivityId;
  116. LuckyBoxDataManager.Instance.VsStatus = response.VsStatus;
  117. return true;
  118. }
  119. }
  120. return false;
  121. }
  122. }
  123. }