InstanceZonesSProxy.cs 9.4 KB

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