LuckyBoxSProxy.cs 2.7 KB

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