using System; using System.Collections.Generic; using System.Linq; using System.Text; using ET; namespace GFGGame { public class InstanceZonesSProxy { //请求剧情关卡数据 public static async ETTask GetInstanceZonesInfos() { M2C_GetInstanceZonesInfos response = null; response = (M2C_GetInstanceZonesInfos)await MessageHelper.SendToServer(new C2M_GetInstanceZonesInfos()); if (response != null) { if (response.Error == ErrorCode.ERR_Success) { InstanceZonesDataManager.InitScoreList(response.ksScore, response.vsScore); InstanceZonesDataManager.InitStarList(response.ksStar, response.vsStar); InstanceZonesDataManager.InitLevelPass(response.ksPass, response.VsPass); } } } //完成剧情对话关卡 public static async ETTask FinishStoryDialogLevel(int levelCfgId) { M2C_FinishInstanceZonesDialog response = null; response = (M2C_FinishInstanceZonesDialog)await MessageHelper.SendToServer(new C2M_FinishInstanceZonesDialog() { LevelCfgId = levelCfgId }); if (response != null) { if (response.Error == ErrorCode.ERR_Success) { List bonusList = StoryBonusDataCache.GetBonusList(response.LevelCfgId, true, true); BonusController.TryShowBonusList(bonusList); InstanceZonesDataManager.TrySetLevelPass(response.LevelCfgId); FunctionOpenDataManager.Instance.CheckHasChapterFunOpen(response.LevelCfgId);//首次通过要检查是否有功能开启 InstanceZonesController.OnFinishStoryLevel(levelCfgId, true, true); return; } } InstanceZonesController.OnFinishStoryLevel(levelCfgId, false, false); } //完成剧情战斗关卡 public static async ETTask FinishStoryFightLevel(int levelCfgId, int score, int npcScore, bool useRecomend) { M2C_FinishInstanceZonesFightLevel response = null; response = (M2C_FinishInstanceZonesFightLevel)await MessageHelper.SendToServer(new C2M_FinishInstanceZonesFightLevel() { LevelCfgId = levelCfgId, Score = score, NpcScore = npcScore, UseRecommend = useRecomend }); if (response != null) { if (response.Error == ErrorCode.ERR_Success) { //更新数据 InstanceZonesDataManager.TryUpdateScore(response.LevelCfgId, response.Score); InstanceZonesDataManager.TryUpdateLevelStar(response.LevelCfgId, response.Star); //展示奖励 List bonusList = StoryBonusDataCache.GetBonusList(response.LevelCfgId, response.HasOnceBonus); if (response.RandomBonusList != null) { foreach (var item in response.RandomBonusList) { var itemData = ItemUtil.createItemData(item.ConfigId, item.Count); bonusList.Add(itemData); } } if (response.HasOnceBonus) { //首次通过要检查是否有功能开启 FunctionOpenDataManager.Instance.CheckHasChapterFunOpen(response.LevelCfgId); } InstanceZonesDataManager.TrySetLevelPass(response.LevelCfgId); ViewManager.Show(ViewName.STORY_FIGHT_RESULT_VIEW, new StoryFightResultData { Result = true, Score = response.Score, FirstPass = response.HasOnceBonus, Star = response.Star, BonusList = bonusList }, null, true); return; } } InstanceZonesController.OnFinishStoryLevel(levelCfgId, false, false); } //剧情战斗关卡失败,更新最高分 public static async ETTask StoryFightLevelFail(int levelCfgId, int score) { M2C_FinishInstanceZonesFightLevelFail response = null; response = (M2C_FinishInstanceZonesFightLevelFail)await MessageHelper.SendToServer(new C2M_FinishInstanceZonesFightLevelFail() { LevelCfgId = levelCfgId, Score = score, }); if (response != null) { if (response.Error == ErrorCode.ERR_Success) { InstanceZonesDataManager.TryUpdateScore(response.LevelCfgId, response.Score); } } } //快速完成关卡战斗 public static async ETTask FinishStoryFightQuickly(int levelCfgId, int times) { M2C_FinishInstanceZonesFightQuickly response = null; response = (M2C_FinishInstanceZonesFightQuickly)await MessageHelper.SendToServer(new C2M_FinishInstanceZonesFightQuickly() { LevelCfgId = levelCfgId, Times = times }); if (response != null) { if (response.Error == ErrorCode.ERR_Success) { List> bonusLists = new List>(); List allList = new List(); foreach (var proto in response.RandomBonusList) { var itemData = ItemUtil.createItemData(proto.ConfigId, proto.Count); allList.Add(itemData); } var index = 0; for (int i = 0; i < response.BonusLengths.Count; ++i) { var len = response.BonusLengths[i]; var baseBonusList = StoryBonusDataCache.GetBaseBonusList(response.LevelCfgId); List bonusList = new List(); if (baseBonusList != null) { bonusList.AddRange(baseBonusList); } if (len > 0) { bonusList.AddRange(allList.GetRange(index, len)); } bonusLists.Add(bonusList); index += len; } EventAgent.DispatchEvent(ConstMessage.STORY_FIGHT_QUICKLY_SUCCESS, bonusLists); } } } } }