InstanceZonesSProxy.cs 7.3 KB

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