InstanceZonesSProxy.cs 8.5 KB

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