InstanceZonesSProxy.cs 7.7 KB

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