using ET; using log4net.Core; using System.Collections.Generic; namespace GFGGame { public class StoryController { public static void ShowLevelView(int levelCfgId) { CalculateHelper.GetStoryChapterLevel(levelCfgId, out int chapterID, out int levelOrder); StoryDataManager.currentChapterCfgId = chapterID; StoryDataManager.currentLevelCfgId = levelCfgId; InstanceZonesDataManager.currentLevelCfgId = levelCfgId; StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId); StoryDataManager.currentLevelOrder = levelOrder; if (levelCfg.fightID.Length > 0) { ViewManager.Show(ViewName.STORY_LEVEL_INFO_VIEW, levelCfgId); } else if (levelCfg.storyStartID.Length > 0) { bool skipable = StoryDataManager.CheckCurrentLevelPass(); ViewManager.Show(ViewName.STORY_DIALOG_VIEW, new object[] { levelCfg.storyStartID, skipable, new OnCompleteStoryDialogCall(OnCompleteChapterStoryDialog) }, null, true); } } public static void ShowCardStoryDialog(CardStoryCfg cardStoryCfg, CardData cardData) { ViewManager.Show(ViewName.STORY_DIALOG_VIEW, new object[] { cardStoryCfg.storyStartID, true, new OnCompleteStoryDialogCall(OnCompleteCardStoryDialog), cardData }, null, true); } public static void ShowPriorStoryDialog() { StoryDataManager.currentChapterCfgId = 10001; StoryDataManager.currentLevelCfgId = 100001001; ViewManager.Show(ViewName.STORY_DIALOG_VIEW, new object[] { StoryDataManager.priorId, false, new OnCompleteStoryDialogCall(OnCompleteChapterStoryDialog) }, null, true); } public static async ETTask CheckStoryFightResult() { var score = EquipDataCache.cacher.totalScore; //客户端先做判断,成功和失败处理不同 var success = StoryDataManager.GetFightResult(score, out var npcScore); if(success) { await StorySProxy.FinishStoryFightLevel(StoryDataManager.currentLevelCfgId, score, npcScore, StoryDataManager.usedRecommend); } else { ViewManager.Show(ViewName.STORY_FIGHT_RESULT_VIEW, new StoryFightResultData { Result = false, Score = score, FirstPass = false, Star = 0 }, null, true); //失败仅判断并更新最高分 if(score > StoryDataManager.GetScoreHighest(StoryDataManager.currentCardId)) { StorySProxy.StoryFightLevelFail(StoryDataManager.currentLevelCfgId, score).Coroutine(); } } } public static void OnFinishStoryLevel(int levelCfgId, bool firstPass) { //判断是否是首次打通最后一关 int nextLevelID = levelCfgId + 1; StoryLevelCfg nextLevelCfg = StoryLevelCfgArray.Instance.GetCfg(nextLevelID); var fistPassLastLvl = (nextLevelCfg == null) && firstPass; if (fistPassLastLvl) { ViewManager.Show(ViewName.STORY_CHAPTER_LIST_VIEW); } else { ViewManager.Show(ViewName.STORY_CHAPTER_VIEW, StoryDataManager.currentChapterCfgId, ViewManager.GetGoBackDatas(ViewName.STORY_CHAPTER_VIEW)); } } private static void OnCompleteChapterStoryDialog(bool isSkip, object param) { if (!StoryDataManager.CheckCurrentLevelPass()) { StorySProxy.FinishStoryDialogLevel(StoryDataManager.currentLevelCfgId).Coroutine(); } } private static void OnCompleteCardStoryDialog(bool isSkip, object param) { CardData cardData = param as CardData; ViewManager.Show(ViewName.CARD_FOSTER_VIEW, cardData, new object[] { ViewName.CARD_DETAIL_VIEW }, true); ViewManager.Show(ViewName.CARD_STORY_VIEW, cardData); } } }