InstanceZonesSProxy.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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. if(filingCfg.suitId != 0)
  48. {
  49. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(filingCfg.suitId);
  50. if (suitCfg.syntheticStoryLevelId == levelCfgId && levelCfgId != StudioDataManager.Instance.GetLuckyBoxActivityID())
  51. {
  52. PromptController.Instance.ShowFloatTextPrompt(string.Format("已解锁{0}套装制作", suitCfg.name));
  53. }
  54. }
  55. }
  56. EventAgent.DispatchEvent(ConstMessage.STORY_LEVEL_CHANGE);
  57. return;
  58. }
  59. }
  60. InstanceZonesController.OnFinishStoryLevel(levelCfgId, false, false);
  61. }
  62. //完成剧情战斗关卡
  63. public static async ETTask FinishStoryFightLevel(int levelCfgId, int score, int npcScore, bool useRecomend)
  64. {
  65. M2C_FinishInstanceZonesFightLevel response = null;
  66. response = (M2C_FinishInstanceZonesFightLevel)await MessageHelper.SendToServer(new C2M_FinishInstanceZonesFightLevel()
  67. {
  68. LevelCfgId = levelCfgId,
  69. Score = score,
  70. NpcScore = npcScore,
  71. UseRecommend = false
  72. });
  73. bool isFirstFinish = false;
  74. if (response != null)
  75. {
  76. if (response.Error == ErrorCode.ERR_Success)
  77. {
  78. //更新数据
  79. InstanceZonesDataManager.TryUpdateScore(response.LevelCfgId, response.Score);
  80. InstanceZonesDataManager.TryUpdateLevelStar(response.LevelCfgId, response.Star);
  81. //展示奖励
  82. List<ItemData> bonusList = StoryBonusDataCache.GetBonusList(response.LevelCfgId, response.HasOnceBonus);
  83. if (response.RandomBonusList != null)
  84. {
  85. foreach (var item in response.RandomBonusList)
  86. {
  87. var itemData = ItemUtil.createItemData(item.ConfigId, item.Count);
  88. bonusList.Add(itemData);
  89. }
  90. }
  91. if (response.HasOnceBonus)
  92. {
  93. isFirstFinish = true;
  94. }
  95. InstanceZonesDataManager.TrySetLevelPass(response.LevelCfgId);
  96. ViewManager.Show<StroyFightResultView>(new StoryFightResultData
  97. {
  98. Result = true,
  99. Score = response.Score,
  100. FirstPass = response.HasOnceBonus,
  101. Star = response.Star,
  102. BonusList = bonusList
  103. }, true);
  104. if (response.HasOnceBonus)
  105. {
  106. FunctionOpenDataManager.Instance.CheckHasChapterFunOpen(response.LevelCfgId);
  107. }
  108. return;
  109. }
  110. }
  111. InstanceZonesController.OnFinishStoryLevel(levelCfgId, false, false);
  112. if (isFirstFinish)
  113. {
  114. //首次通过要检查是否有功能开启
  115. FunctionOpenDataManager.Instance.CheckHasChapterFunOpen(response.LevelCfgId);
  116. EventAgent.DispatchEvent(ConstMessage.STORY_LEVEL_CHANGE);
  117. }
  118. }
  119. //剧情战斗关卡失败,更新最高分
  120. public static async ETTask StoryFightLevelFail(int levelCfgId, int score)
  121. {
  122. M2C_FinishInstanceZonesFightLevelFail response = null;
  123. response = (M2C_FinishInstanceZonesFightLevelFail)await MessageHelper.SendToServer(new C2M_FinishInstanceZonesFightLevelFail()
  124. {
  125. LevelCfgId = levelCfgId,
  126. Score = score,
  127. });
  128. if (response != null)
  129. {
  130. if (response.Error == ErrorCode.ERR_Success)
  131. {
  132. InstanceZonesDataManager.TryUpdateScore(response.LevelCfgId, response.Score);
  133. }
  134. }
  135. }
  136. //快速完成关卡战斗
  137. public static async ETTask<List<ItemData>> FinishStoryFightQuickly(int levelCfgId, int times)
  138. {
  139. M2C_FinishInstanceZonesFightQuickly response = null;
  140. response = (M2C_FinishInstanceZonesFightQuickly)await MessageHelper.SendToServer(new C2M_FinishInstanceZonesFightQuickly()
  141. {
  142. LevelCfgId = levelCfgId,
  143. Times = times
  144. });
  145. if (response != null)
  146. {
  147. if (response.Error == ErrorCode.ERR_Success)
  148. {
  149. List<List<ItemData>> bonusLists = new List<List<ItemData>>();
  150. List<ItemData> allList = new List<ItemData>();
  151. foreach (var proto in response.RandomBonusList)
  152. {
  153. var itemData = ItemUtil.createItemData(proto.ConfigId, proto.Count);
  154. allList.Add(itemData);
  155. }
  156. var baseBonusList = StoryBonusDataCache.GetBaseBonusList(response.LevelCfgId);
  157. if (baseBonusList != null)
  158. {
  159. allList.AddRange(baseBonusList);
  160. }
  161. // var index = 0;
  162. // for (int i = 0; i < response.BonusLengths.Count; ++i)
  163. // {
  164. // var len = response.BonusLengths[i];
  165. // var baseBonusList = StoryBonusDataCache.GetBaseBonusList(response.LevelCfgId);
  166. // List<ItemData> bonusList = new List<ItemData>();
  167. // if (baseBonusList != null)
  168. // {
  169. // bonusList.AddRange(baseBonusList);
  170. // }
  171. // if (len > 0)
  172. // {
  173. // bonusList.AddRange(allList.GetRange(index, len));
  174. // }
  175. // bonusLists.Add(bonusList);
  176. // index += len;
  177. // }
  178. return allList;
  179. // EventAgent.DispatchEvent(ConstMessage.STORY_FIGHT_QUICKLY_SUCCESS, bonusLists);
  180. }
  181. }
  182. return null;
  183. }
  184. }
  185. }