InstanceZonesSProxy.cs 7.0 KB

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