MainStorySProxy.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using ET;
  2. using GFGGame;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace ET
  9. {
  10. public class M2C_NoticeMainStoryBoxBonusStateHandler : AMHandler<M2C_NoticeMainStoryBoxBonusState>
  11. {
  12. protected override async ETTask Run(Session session, M2C_NoticeMainStoryBoxBonusState message)
  13. {
  14. MainStoryDataManager.UpdateBoxBonusStates(message.ChapterId, message.BoxStates);
  15. EventAgent.DispatchEvent(ConstMessage.NOTICE_MAINSTORY_BOXBONUS_STATE);
  16. await ETTask.CompletedTask;
  17. }
  18. }
  19. }
  20. namespace GFGGame
  21. {
  22. public class MainStorySProxy
  23. {
  24. //请求剧情关卡数据
  25. public static async ETTask GetStoryBonusInfos()
  26. {
  27. M2C_GetMainStoryInfos response = null;
  28. response = (M2C_GetMainStoryInfos)await MessageHelper.SendToServer(new C2M_GetMainStoryInfos());
  29. if (response != null)
  30. {
  31. if (response.Error == ErrorCode.ERR_Success)
  32. {
  33. MainStoryDataManager.InitBoxBonusStates(response.KsBonusState, response.VsBonusState);
  34. }
  35. }
  36. }
  37. //请求剧情关卡数据
  38. public static async ETTask<bool> GetMainStoryBoxBonus(int chapterId, int index)
  39. {
  40. M2C_GetMainStoryBoxBonus response = null;
  41. response = (M2C_GetMainStoryBoxBonus)await MessageHelper.SendToServer(new C2M_GetMainStoryBoxBonus() { ChapterId = chapterId, Index = index });
  42. if (response != null)
  43. {
  44. if (response.Error == ErrorCode.ERR_Success)
  45. {
  46. MainStoryDataManager.UpdateBoxBonusStates(response.ChapterId, response.BoxStates);
  47. return true;
  48. }
  49. }
  50. return false;
  51. }
  52. //请求章节奖励数据
  53. public static async ETTask<bool> GetStoryBonusDate()
  54. {
  55. S2C_GetChapterPassStatus response = null;
  56. response = (S2C_GetChapterPassStatus)await MessageHelper.SendToServer(new C2S_GetChapterPassStatus() { });
  57. if (response != null)
  58. {
  59. if (response.Error == ErrorCode.ERR_Success)
  60. {
  61. MainStoryDataManager.ChapterRewardStatusDic.Clear();
  62. for(int i = 0;i < response.PassStatusKs.Count;i++)
  63. {
  64. MainStoryDataManager.ChapterRewardStatusDic.Add(response.PassStatusKs[i], response.PassStatusVs[i]);
  65. }
  66. return true;
  67. }
  68. }
  69. return false;
  70. }
  71. //领取章节奖励数据
  72. public static async ETTask<bool> GetStoryBonusReward(int id)
  73. {
  74. S2C_GethapterPassReward response = null;
  75. response = (S2C_GethapterPassReward)await MessageHelper.SendToServer(new C2S_GethapterPassReward() { ChapterId = id});
  76. if (response != null)
  77. {
  78. if (response.Error == ErrorCode.ERR_Success)
  79. {
  80. for (int i = 0; i < response.PassStatusKs.Count; i++)
  81. {
  82. if(response.PassStatusKs[i] == id)
  83. {
  84. MainStoryDataManager.ChapterRewardStatusDic[id] = response.PassStatusVs[i];
  85. }
  86. }
  87. BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(response.BonusList));
  88. return true;
  89. }
  90. }
  91. return false;
  92. }
  93. }
  94. }