InstanceZonesSProxy.cs 9.1 KB

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