1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- 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)
- {
- StoryFightCfg storyFightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
- if (storyFightCfg == null)
- {
- Debug.LogError(string.Format("战斗id:{0} 无配置", levelCfg.fightID));
- return;
- }
- ViewManager.Show(ViewName.STORY_LEVEL_INFO_VIEW, levelCfgId);
- }
- else if (!string.IsNullOrEmpty(levelCfg.storyStartID))
- {
- List<StoryDialogCfg> storyDialogCfg = StoryDialogCfgArray.Instance.GetCfgs(levelCfg.storyStartID);
- if (storyDialogCfg.Count <= 0)
- {
- Debug.LogError(string.Format("剧情id:{0} 无配置", levelCfg.storyStartID));
- return;
- }
- 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);
- }
- }
- }
- }
|