123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- 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<StoryLevelInfoView>(new object[] { levelCfgId, needitemId, needItemCount });
- }
- else if (!string.IsNullOrEmpty(levelCfg.storyStartID))
- {
- List<StoryDialogCfg> storyDialogCfg = StoryDialogCfgArray.Instance.GetCfgsByid(levelCfg.storyStartID);
- if (storyDialogCfg.Count <= 0)
- {
- Debug.LogError(string.Format("剧情id:{0} 无配置", levelCfg.storyStartID));
- return;
- }
- object[] gobackparams;
- if (levelCfg.type == ConstInstanceZonesType.Studio && levelCfg.subType == ConstInstanceZonesSubType.Hard3)
- {
- object param = ViewManager.GetUIView(nameof(StudioFilingView)).viewData;
- gobackparams = new object[] { typeof(StudioFilingView).FullName, param };
- }
- else
- {
- gobackparams = new object[] { typeof(StoryChapterView).FullName, MainStoryDataManager.currentChapterCfgId };
- }
- //, new object[] { typeof(StoryChapterView).FullName, MainStoryDataManager.currentChapterCfgId }
- bool skipable = MainStoryDataManager.CheckCurrentLevelPass();
- ViewManager.Show<StoryDialogView>(new object[] { levelCfg.storyStartID, skipable, new OnCompleteStoryDialogCall(OnCompleteChapterStoryDialog) }, gobackparams, true);
- }
- }
- public static async ETTask CheckStoryFightResult()
- {
- StoryLevelCfg storyLevelCfg = StoryLevelCfgArray.Instance.GetCfg(InstanceZonesDataManager.currentLevelCfgId);
- if (storyLevelCfg.type == ConstInstanceZonesType.Studio && storyLevelCfg.subType == ConstInstanceZonesSubType.Hard3)
- {
- StudioCfg filingCfg = StudioCfgArray.Instance.GetCfg(StudioDataManager.Instance.filingChapterId);
- float addition = StudioDataManager.Instance.GetAdditionBySuitId(filingCfg.suitId);
- 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<StroyFightResultView>(new StoryFightResultData
- {
- Result = false,
- Score = score,
- FirstPass = false,
- Star = 0
- }, null, true);
- //失败仅判断并更新最高分
- if (score > InstanceZonesDataManager.GetScoreHighest(InstanceZonesDataManager.currentCardId))
- {
- InstanceZonesSProxy.StoryFightLevelFail(InstanceZonesDataManager.currentLevelCfgId, score).Coroutine();
- }
- }
- }
- public static void OnCompleteChapterStoryDialog(bool isSkip, object param)
- {
- if (!MainStoryDataManager.CheckCurrentLevelPass())
- {
- 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);
- }
- }
- }
|