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, int needitemId = 0, int needItemCount = 0) { _onFinishStoryLevelCall = onFinishStoryLevelCall; InstanceZonesDataManager.currentLevelCfgId = levelCfgId; StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelCfgId); if (levelCfg.fightID.Length > 0) { StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID); if (storyFightCfg == null) { Debug.LogError(string.Format("战斗id:{0} 无配置", levelCfg.fightID)); return; } ViewManager.Show(new object[] { levelCfgId, needitemId, needItemCount }); } else if (!string.IsNullOrEmpty(levelCfg.storyStartID)) { List storyDialogCfg = StoryDialogCfgArray.Instance.GetCfgsByid(levelCfg.storyStartID); if (storyDialogCfg.Count <= 0) { Debug.LogError(string.Format("剧情id:{0} 无配置", levelCfg.storyStartID)); return; } //, new object[] { typeof(StoryChapterView).FullName, MainStoryDataManager.currentChapterCfgId } bool skipable = MainStoryDataManager.CheckCurrentLevelPass(); ViewManager.Show(new object[] { levelCfg.storyStartID, skipable, new OnCompleteStoryDialogCall(OnCompleteChapterStoryDialog),null,false }, true); } } public static async ETTask CheckStoryFightResult() { StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId); //if (storyLevelCfg.type == ConstInstanceZonesType.Studio && storyLevelCfg.subType == ConstInstanceZonesSubType.Hard3) //{ // float addition = StudioDataManager.Instance.GetAddition(); // addition = addition / 10000 * FightDataManager.Instance.totalScore; // FightDataManager.Instance.totalScore += (int)Math.Round(addition); //} var score = FightDataManager.Instance.totalScore; //客户端先做判断,成功和失败处理不同 var success = InstanceZonesDataManager.GetFightResult(score, out var npcScore); if (success) { await InstanceZonesSProxy.FinishStoryFightLevel(InstanceZonesDataManager.currentLevelCfgId, score, npcScore, InstanceZonesDataManager.usedRecommend); } else { ViewManager.Show(new StoryFightResultData { Result = false, Score = score, FirstPass = false, Star = 0 }, true); //失败仅判断并更新最高分 if (score > InstanceZonesDataManager.GetScoreHighest(InstanceZonesDataManager.currentCardId)) { InstanceZonesSProxy.StoryFightLevelFail(InstanceZonesDataManager.currentLevelCfgId, score).Coroutine(); } } } public static void OnCompleteChapterStoryDialog(bool isSkip, object param) { if (!MainStoryDataManager.CheckCurrentLevelPass() && isSkip) { InstanceZonesSProxy.FinishStoryDialogLevel(InstanceZonesDataManager.currentLevelCfgId).Coroutine(); } else { OnFinishStoryLevel(InstanceZonesDataManager.currentLevelCfgId, false, false); } } public static void OnFinishStoryLevel(int levelCfgId, bool firstPass, bool success) { _onFinishStoryLevelCall?.Invoke(levelCfgId, firstPass, success); } } }