StorySProxy.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using ET;
  6. namespace GFGGame
  7. {
  8. public class StorySProxy
  9. {
  10. //请求剧情关卡数据
  11. public static async ETTask GetStoryInfos()
  12. {
  13. M2C_GetStoryInfos response = null;
  14. response = (M2C_GetStoryInfos)await MessageHelper.SendToServer(new C2M_GetStoryInfos());
  15. if(response != null)
  16. {
  17. if(response.Error == ErrorCode.ERR_Success)
  18. {
  19. StoryDataManager.InitScoreList(response.ksScore, response.vsScore);
  20. StoryDataManager.InitStarList(response.ksStar, response.vsStar);
  21. StoryDataManager.InitBoxBonusStates(response.ksBonusState, response.vsBonusState);
  22. }
  23. }
  24. }
  25. //完成剧情对话关卡
  26. public static async ETTask FinishStoryDialogLevel(int levelCfgId)
  27. {
  28. M2C_FinishStoryDialog response = null;
  29. response = (M2C_FinishStoryDialog)await MessageHelper.SendToServer(new C2M_FinishStoryDialog()
  30. {
  31. LevelCfgId = levelCfgId
  32. });
  33. if (response != null)
  34. {
  35. if (response.Error == ErrorCode.ERR_Success)
  36. {
  37. List<ItemData> bonusList = StoryBonusDataCache.GetBonusList(response.LevelCfgId, true, true);
  38. BonusController.TryShowBonusList(bonusList);
  39. }
  40. }
  41. }
  42. //完成剧情战斗关卡
  43. public static async ETTask FinishStoryFightLevel(int levelCfgId, int score, int npcScore, bool useRecomend)
  44. {
  45. M2C_FinishStoryFightLevel response = null;
  46. response = (M2C_FinishStoryFightLevel)await MessageHelper.SendToServer(new C2M_FinishStoryFightLevel()
  47. {
  48. LevelCfgId = levelCfgId,
  49. Score = score,
  50. NpcScore = npcScore,
  51. UseRecommend = useRecomend
  52. });
  53. if(response != null)
  54. {
  55. if(response.Error == ErrorCode.ERR_Success)
  56. {
  57. //更新数据
  58. StoryDataManager.TryUpdateScore(response.LevelCfgId, response.Score);
  59. StoryDataManager.TryUpdateLevelStar(response.LevelCfgId, response.Star);
  60. CalculateHelper.GetStoryChapterLevel(response.LevelCfgId, out var chapter, out var level);
  61. StoryDataManager.UpdateBoxBonusStates(chapter, response.BoxStates);
  62. //展示奖励
  63. List<ItemData> bonusList = StoryBonusDataCache.GetBonusList(response.LevelCfgId, response.HasOnceBonus);
  64. if(response.RandomBonusList != null)
  65. {
  66. foreach(var item in response.RandomBonusList)
  67. {
  68. var itemData = ItemUtil.createItemData(item.ConfigId, item.Count);
  69. bonusList.Add(itemData);
  70. }
  71. }
  72. if(response.HasOnceBonus)
  73. {
  74. //首次通过要检查是否有功能开启
  75. FunctionOpenDataManager.Instance.CheckHasChapterFunOpen(GameGlobal.myNumericComponent.GetAsInt(NumericType.Chapter) + 1, GameGlobal.myNumericComponent.GetAsInt(NumericType.ChapterLvl));
  76. }
  77. ViewManager.Show(ViewName.STORY_FIGHT_RESULT_VIEW, new StoryFightResultData
  78. {
  79. Result = true,
  80. Score = response.Score,
  81. FirstPass = response.HasOnceBonus,
  82. Star = response.Star,
  83. BonusList = bonusList
  84. }, null, true);
  85. return;
  86. }
  87. }
  88. //异常返回到关卡列表界面
  89. ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, StoryDataManager.currentChapter, ViewManager.GetGoBackDatas(ViewName.STORY_CHAPTER_VIEW));
  90. }
  91. //完成剧情战斗关卡失败,更新最高分
  92. public static async ETTask FinishStoryFightLevelFail(int levelCfgId, int score)
  93. {
  94. M2C_FinishStoryFightLevelFail response = null;
  95. response = (M2C_FinishStoryFightLevelFail)await MessageHelper.SendToServer(new C2M_FinishStoryFightLevelFail()
  96. {
  97. LevelCfgId = levelCfgId,
  98. Score = score,
  99. });
  100. if (response != null)
  101. {
  102. if (response.Error == ErrorCode.ERR_Success)
  103. {
  104. StoryDataManager.TryUpdateScore(response.LevelCfgId, response.Score);
  105. }
  106. }
  107. }
  108. }
  109. }