InstanceZonesSProxy.cs 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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 InstanceZonesSProxy
  9. {
  10. //请求剧情关卡数据
  11. public static async ETTask GetInstanceZonesInfos()
  12. {
  13. M2C_GetInstanceZonesInfos response = null;
  14. response = (M2C_GetInstanceZonesInfos)await MessageHelper.SendToServer(new C2M_GetInstanceZonesInfos());
  15. if (response != null)
  16. {
  17. if (response.Error == ErrorCode.ERR_Success)
  18. {
  19. InstanceZonesDataManager.InitScoreList(response.ksScore, response.vsScore);
  20. InstanceZonesDataManager.InitStarList(response.ksStar, response.vsStar);
  21. InstanceZonesDataManager.InitLevelPass(response.ksPass, response.VsPass);
  22. EventAgent.DispatchEvent(ConstMessage.STORY_LEVEL_CHANGE);
  23. }
  24. }
  25. }
  26. //完成剧情对话关卡
  27. public static async ETTask FinishStoryDialogLevel(int levelCfgId)
  28. {
  29. M2C_FinishInstanceZonesDialog response = null;
  30. response = (M2C_FinishInstanceZonesDialog)await MessageHelper.SendToServer(new C2M_FinishInstanceZonesDialog()
  31. {
  32. LevelCfgId = levelCfgId
  33. });
  34. if (response != null)
  35. {
  36. if (response.Error == ErrorCode.ERR_Success)
  37. {
  38. List<ItemData> bonusList = StoryBonusDataCache.GetBonusList(response.LevelCfgId, true);
  39. InstanceZonesDataManager.TrySetLevelPass(response.LevelCfgId);
  40. InstanceZonesController.OnFinishStoryLevel(levelCfgId, true, true);
  41. FunctionOpenDataManager.Instance.CheckHasChapterFunOpen(response.LevelCfgId);//首次通过要检查是否有功能开启
  42. BonusController.TryShowBonusList(bonusList);
  43. StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId);
  44. if (storyLevelCfg.type == ConstInstanceZonesType.Studio && storyLevelCfg.subType == ConstInstanceZonesSubType.Hard3)
  45. {
  46. StudioCfg filingCfg = StudioCfgArray.Instance.GetCfg(StudioDataManager.Instance.filingChapterId);
  47. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(filingCfg.suitId);
  48. if (suitCfg.syntheticStoryLevelId == levelCfgId && levelCfgId != StudioDataManager.Instance.luckyBoxFilingChapterId)
  49. {
  50. PromptController.Instance.ShowFloatTextPrompt(string.Format("已解锁{0}套装制作", suitCfg.name));
  51. }
  52. }
  53. EventAgent.DispatchEvent(ConstMessage.STORY_LEVEL_CHANGE);
  54. return;
  55. }
  56. }
  57. InstanceZonesController.OnFinishStoryLevel(levelCfgId, false, false);
  58. }
  59. //完成剧情战斗关卡
  60. public static async ETTask FinishStoryFightLevel(int levelCfgId, int score, int npcScore, bool useRecomend)
  61. {
  62. M2C_FinishInstanceZonesFightLevel response = null;
  63. response = (M2C_FinishInstanceZonesFightLevel)await MessageHelper.SendToServer(new C2M_FinishInstanceZonesFightLevel()
  64. {
  65. LevelCfgId = levelCfgId,
  66. Score = score,
  67. NpcScore = npcScore,
  68. UseRecommend = false
  69. });
  70. bool isFirstFinish = false;
  71. if (response != null)
  72. {
  73. if (response.Error == ErrorCode.ERR_Success)
  74. {
  75. //更新数据
  76. InstanceZonesDataManager.TryUpdateScore(response.LevelCfgId, response.Score);
  77. InstanceZonesDataManager.TryUpdateLevelStar(response.LevelCfgId, response.Star);
  78. //展示奖励
  79. List<ItemData> bonusList = StoryBonusDataCache.GetBonusList(response.LevelCfgId, response.HasOnceBonus);
  80. if (response.RandomBonusList != null)
  81. {
  82. foreach (var item in response.RandomBonusList)
  83. {
  84. var itemData = ItemUtil.createItemData(item.ConfigId, item.Count);
  85. bonusList.Add(itemData);
  86. }
  87. }
  88. if (response.HasOnceBonus)
  89. {
  90. isFirstFinish = true;
  91. }
  92. InstanceZonesDataManager.TrySetLevelPass(response.LevelCfgId);
  93. ViewManager.Show(ViewName.STORY_FIGHT_RESULT_VIEW, new StoryFightResultData
  94. {
  95. Result = true,
  96. Score = response.Score,
  97. FirstPass = response.HasOnceBonus,
  98. Star = response.Star,
  99. BonusList = bonusList
  100. }, null, true);
  101. if (response.HasOnceBonus)
  102. {
  103. FunctionOpenDataManager.Instance.CheckHasChapterFunOpen(response.LevelCfgId);
  104. }
  105. return;
  106. }
  107. }
  108. InstanceZonesController.OnFinishStoryLevel(levelCfgId, false, false);
  109. if (isFirstFinish)
  110. {
  111. //首次通过要检查是否有功能开启
  112. FunctionOpenDataManager.Instance.CheckHasChapterFunOpen(response.LevelCfgId);
  113. EventAgent.DispatchEvent(ConstMessage.STORY_LEVEL_CHANGE);
  114. }
  115. }
  116. //剧情战斗关卡失败,更新最高分
  117. public static async ETTask StoryFightLevelFail(int levelCfgId, int score)
  118. {
  119. M2C_FinishInstanceZonesFightLevelFail response = null;
  120. response = (M2C_FinishInstanceZonesFightLevelFail)await MessageHelper.SendToServer(new C2M_FinishInstanceZonesFightLevelFail()
  121. {
  122. LevelCfgId = levelCfgId,
  123. Score = score,
  124. });
  125. if (response != null)
  126. {
  127. if (response.Error == ErrorCode.ERR_Success)
  128. {
  129. InstanceZonesDataManager.TryUpdateScore(response.LevelCfgId, response.Score);
  130. }
  131. }
  132. }
  133. //快速完成关卡战斗
  134. public static async ETTask<List<ItemData>> FinishStoryFightQuickly(int levelCfgId, int times)
  135. {
  136. M2C_FinishInstanceZonesFightQuickly response = null;
  137. response = (M2C_FinishInstanceZonesFightQuickly)await MessageHelper.SendToServer(new C2M_FinishInstanceZonesFightQuickly()
  138. {
  139. LevelCfgId = levelCfgId,
  140. Times = times
  141. });
  142. if (response != null)
  143. {
  144. if (response.Error == ErrorCode.ERR_Success)
  145. {
  146. List<List<ItemData>> bonusLists = new List<List<ItemData>>();
  147. List<ItemData> allList = new List<ItemData>();
  148. foreach (var proto in response.RandomBonusList)
  149. {
  150. var itemData = ItemUtil.createItemData(proto.ConfigId, proto.Count);
  151. allList.Add(itemData);
  152. }
  153. var baseBonusList = StoryBonusDataCache.GetBaseBonusList(response.LevelCfgId);
  154. if (baseBonusList != null)
  155. {
  156. allList.AddRange(baseBonusList);
  157. }
  158. // var index = 0;
  159. // for (int i = 0; i < response.BonusLengths.Count; ++i)
  160. // {
  161. // var len = response.BonusLengths[i];
  162. // var baseBonusList = StoryBonusDataCache.GetBaseBonusList(response.LevelCfgId);
  163. // List<ItemData> bonusList = new List<ItemData>();
  164. // if (baseBonusList != null)
  165. // {
  166. // bonusList.AddRange(baseBonusList);
  167. // }
  168. // if (len > 0)
  169. // {
  170. // bonusList.AddRange(allList.GetRange(index, len));
  171. // }
  172. // bonusLists.Add(bonusList);
  173. // index += len;
  174. // }
  175. return allList;
  176. // EventAgent.DispatchEvent(ConstMessage.STORY_FIGHT_QUICKLY_SUCCESS, bonusLists);
  177. }
  178. }
  179. return null;
  180. }
  181. }
  182. }