using ET; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; namespace GFGGame { //所有副本关卡通用类 public class InstanceZonesController { public delegate void OnFinishStoryLevelCall(int levelCfgId, bool firstPass, bool success); private static OnFinishStoryLevelCall _onFinishStoryLevelCall; public static void ShowLevelView(int levelCfgId, OnFinishStoryLevelCall onFinishStoryLevelCall) { _onFinishStoryLevelCall = onFinishStoryLevelCall; InstanceZonesDataManager.currentLevelCfgId = levelCfgId; StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId); if (levelCfg.fightID.Length > 0) { ViewManager.Show(ViewName.STORY_LEVEL_INFO_VIEW, levelCfgId); } else if (!string.IsNullOrEmpty(levelCfg.storyStartID)) { bool skipable = MainStoryDataManager.CheckCurrentLevelPass(); ViewManager.Show(ViewName.STORY_DIALOG_VIEW, new object[] { levelCfg.storyStartID, skipable, new OnCompleteStoryDialogCall(OnCompleteChapterStoryDialog) }, null, true); } } public static void OnFinishStoryLevel(int levelCfgId, bool firstPass, bool success) { _onFinishStoryLevelCall?.Invoke(levelCfgId, firstPass, success); } public static async ETTask CheckStoryFightResult() { var score = EquipDataCache.cacher.totalScore; //客户端先做判断,成功和失败处理不同 var success = InstanceZonesDataManager.GetFightResult(score, out var npcScore); if (success) { await InstanceZonesSProxy.FinishStoryFightLevel(InstanceZonesDataManager.currentLevelCfgId, score, npcScore, InstanceZonesDataManager.usedRecommend); } else { ViewManager.Show(ViewName.STORY_FIGHT_RESULT_VIEW, new StoryFightResultData { Result = false, Score = score, FirstPass = false, Star = 0 }, null, true); //失败仅判断并更新最高分 if (score > InstanceZonesDataManager.GetScoreHighest(InstanceZonesDataManager.currentCardId)) { InstanceZonesSProxy.StoryFightLevelFail(InstanceZonesDataManager.currentLevelCfgId, score).Coroutine(); } } } private static void OnCompleteChapterStoryDialog(bool isSkip, object param) { if (!MainStoryDataManager.CheckCurrentLevelPass()) { InstanceZonesSProxy.FinishStoryDialogLevel(InstanceZonesDataManager.currentLevelCfgId).Coroutine(); } else { OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, false, false); } } } }