| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- using ET;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using cfg.GfgCfg;
- 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 = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(levelCfgId);
- if (levelCfg.FightID.Length > 0)
- {
- StoryFightCfg storyFightCfg =
- CommonDataManager.Tables.TblStoryFightCfg.GetOrDefault(int.Parse(levelCfg.FightID));
- if (storyFightCfg == null)
- {
- Debug.LogError(string.Format("战斗id:{0} 无配置", levelCfg.FightID));
- return;
- }
- if (levelCfg.Type == 6 && levelCfg.SubType == 2)
- {
- ViewManager.Show<TimeTracingLevelInfoView>(new object[] { levelCfgId, needitemId, needItemCount });
- }
- else
- {
- ViewManager.Show<StoryLevelInfoView>(new object[] { levelCfgId, needitemId, needItemCount });
- }
- }
- else if (!string.IsNullOrEmpty(levelCfg.StoryStartID))
- {
- List<StoryDialogCfg> storyDialogCfg = CommonDataManager.Tables.TblStoryDialogCfg.DataList
- .Where(a => a.Id == int.Parse(levelCfg.StoryStartID)).ToList();
- 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<StoryDialogView>(
- new object[]
- {
- levelCfg.StoryStartID, skipable, new OnCompleteStoryDialogCall(OnCompleteChapterStoryDialog),
- null, false
- }, true, false);
- }
- }
- 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<StroyFightResultView>(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);
- }
- }
- }
|