using System; using System.Collections.Generic; using System.Linq; using System.Text; using ET; namespace GFGGame { public class StorySProxy { //请求剧情关卡数据 public static async ETTask GetStoryInfos() { M2C_GetStoryInfos response = null; response = (M2C_GetStoryInfos)await MessageHelper.SendToServer(new C2M_GetStoryInfos()); if(response != null) { if(response.Error == ErrorCode.ERR_Success) { StoryDataManager.InitScoreList(response.ksScore, response.vsScore); StoryDataManager.InitStarList(response.ksStar, response.vsStar); StoryDataManager.InitBoxBonusStates(response.ksBonusState, response.vsBonusState); } } } //完成剧情对话关卡 public static async ETTask FinishStoryDialogLevel(int levelCfgId) { M2C_FinishStoryDialog response = null; response = (M2C_FinishStoryDialog)await MessageHelper.SendToServer(new C2M_FinishStoryDialog() { LevelCfgId = levelCfgId }); if (response != null) { if (response.Error == ErrorCode.ERR_Success) { List bonusList = StoryBonusDataCache.GetBonusList(response.LevelCfgId, true, true); BonusController.TryShowBonusList(bonusList); FunctionOpenDataManager.Instance.CheckHasChapterFunOpen(GameGlobal.myNumericComponent.GetAsInt(NumericType.Chapter) + 1, GameGlobal.myNumericComponent.GetAsInt(NumericType.ChapterLvl));//首次通过要检查是否有功能开启 StoryController.OnFinishStoryLevel(levelCfgId, true); return; } } //异常返回到关卡列表界面 ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, StoryDataManager.currentChapterCfgId, ViewManager.GetGoBackDatas(ViewName.STORY_CHAPTER_VIEW)); } //完成剧情战斗关卡 public static async ETTask FinishStoryFightLevel(int levelCfgId, int score, int npcScore, bool useRecomend) { M2C_FinishStoryFightLevel response = null; response = (M2C_FinishStoryFightLevel)await MessageHelper.SendToServer(new C2M_FinishStoryFightLevel() { LevelCfgId = levelCfgId, Score = score, NpcScore = npcScore, UseRecommend = useRecomend }); if(response != null) { if(response.Error == ErrorCode.ERR_Success) { //更新数据 StoryDataManager.TryUpdateScore(response.LevelCfgId, response.Score); StoryDataManager.TryUpdateLevelStar(response.LevelCfgId, response.Star); CalculateHelper.GetStoryChapterLevel(response.LevelCfgId, out var chapter, out var level); StoryDataManager.UpdateBoxBonusStates(chapter, response.BoxStates); //展示奖励 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(GameGlobal.myNumericComponent.GetAsInt(NumericType.Chapter) + 1, GameGlobal.myNumericComponent.GetAsInt(NumericType.ChapterLvl)); } 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; } } //异常返回到关卡列表界面 ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, StoryDataManager.currentChapterCfgId, ViewManager.GetGoBackDatas(ViewName.STORY_CHAPTER_VIEW)); } //剧情战斗关卡失败,更新最高分 public static async ETTask StoryFightLevelFail(int levelCfgId, int score) { M2C_FinishStoryFightLevelFail response = null; response = (M2C_FinishStoryFightLevelFail)await MessageHelper.SendToServer(new C2M_FinishStoryFightLevelFail() { LevelCfgId = levelCfgId, Score = score, }); if (response != null) { if (response.Error == ErrorCode.ERR_Success) { StoryDataManager.TryUpdateScore(response.LevelCfgId, response.Score); } } } //快速完成关卡战斗 public static async ETTask FinishStoryFightQuickly(int levelCfgId, int times) { M2C_FinishStoryFightQuickly response = null; response = (M2C_FinishStoryFightQuickly)await MessageHelper.SendToServer(new C2M_FinishStoryFightQuickly() { 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); } } } } }