LuckyBoxSProxy.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. ET.Log.Debug("打印测试----------服务器下发-------");
  10. LuckyBoxDataManager.Instance.UpdateFreeTime(message.LuckyBoxId, message.FreeTime);
  11. await ETTask.CompletedTask;
  12. }
  13. }
  14. }
  15. namespace GFGGame
  16. {
  17. public class LuckyBoxSProxy
  18. {
  19. //抽奖
  20. public static async ETTask<bool> ReqGetBonus(int luckyBoxId, int times, bool free = false)
  21. {
  22. M2C_DrawLuckyBox response = null;
  23. response = (M2C_DrawLuckyBox)await MessageHelper.SendToServer(new C2M_DrawLuckyBox() { LuckyBoxId = luckyBoxId, Times = times, Free = free });
  24. if (response != null)
  25. {
  26. if (response.Error == ErrorCode.ERR_Success)
  27. {
  28. ActivityOpenCfg activityOpenCfg = ActivityOpenCfgArray.Instance.GetCfg(ActivityDataManager.Instance.actLuckyBoxId);
  29. if (activityOpenCfg != null && activityOpenCfg.paramsArr[0] == luckyBoxId)
  30. {
  31. ActivityDataManager.Instance.allPlayTimes += response.Times;
  32. }
  33. LuckyBoxDataManager.Instance.times = response.Times;
  34. // LuckyBoxDataManager.Instance.luckyBoxIndex = response.LuckyBoxId;
  35. LuckyBoxDataManager.Instance.RewardList = ItemUtil.CreateItemDataList(response.bonusList);
  36. return true;
  37. }
  38. }
  39. return false;
  40. }
  41. //请求轮换抽奖活动信息
  42. public static async ETTask<int> ReqGetLuckyBoxRotatingInfo()
  43. {
  44. S2C_GetLuckyBoxRotatingInfo response = null;
  45. response = (S2C_GetLuckyBoxRotatingInfo)await MessageHelper.SendToServer(new C2S_GetLuckyBoxRotatingInfo() { });
  46. if (response != null)
  47. {
  48. if (response.Error == ErrorCode.ERR_Success)
  49. {
  50. LuckyBoxDataManager.Instance.RotatingId = response.RotatingId;
  51. return response.RotatingId;
  52. }
  53. }
  54. return 0;
  55. }
  56. //请求抽奖初始信息
  57. public static async ETTask ReqGetLuckyBoxInfo()
  58. {
  59. S2C_GetLuckyBoxInfo response = null;
  60. response = (S2C_GetLuckyBoxInfo)await MessageHelper.SendToServer(new C2S_GetLuckyBoxInfo() { });
  61. if(response != null)
  62. {
  63. if (response.Error == ErrorCode.ERR_Success)
  64. {
  65. ET.Log.Debug("打印测试-------请求抽奖初始信息---------" + response.Error);
  66. LuckyBoxDataManager.Instance.InitServerData(response);
  67. }
  68. }
  69. }
  70. }
  71. }