using cfg.GuideCfg;
using System;
using System.Linq;
using Cysharp.Threading.Tasks;
using Gameplay.Level;
using UnityEngine.UI;
using UnityEngine;
using Framework;
using cfg.LevelCfg;
using Gameplay.Area;
using Gameplay.Skill;
using Gameplay.Unit;
using Gameplay.Character;
using Sirenix.OdinInspector.Editor;
using Framework.Condition;
namespace Gameplay.Guide
{
///
/// 引导状态
///
internal enum E_GuideState
{
///
/// 等待引导
///
Idle,
///
/// 引导中
///
Guiding,
///
/// 引导完成
///
Complete,
}
///
/// 引导步骤基类
///
public abstract class GuideStepBase
{
///
/// 是否等待中
///
private bool isWaiting;
///
/// 完成标记
///
private bool isComplete;
///
/// 引导状态
///
private E_GuideState guideState;
///
/// 引导配置
///
public DataGuideCfg Cfg { get; private set; }
///
/// 是否引导中
///
public bool IsGuiding { get { return E_GuideState.Guiding == guideState; } }
public GuideStepBase(DataGuideCfg cfg)
{
Cfg = cfg;
guideState = E_GuideState.Idle;
isWaiting = true;
isComplete = false;
ConditionReactor.Instance.AddReaction(cfg.CompleteCondition, OnCompleteByCondition);
}
///
/// 开始引导
///
public async void StartGuide()
{
guideState = E_GuideState.Guiding;
isWaiting = true;
DebugUtil.Log($"开始id为{Cfg.Id}的引导,延迟{Cfg.StepStartDelay}秒开始"); // #00FA9A绿色
await DoBeforeGuide();
await UniTask.Delay((int)(Cfg.StepStartDelay * 1000f)); // 延迟时间开始
isWaiting = false;
DoRealBeforeGuide();
DebugUtil.Log($"实际执行id为{Cfg.Id}的引导"); // #00FA9A绿色
DoGuide();
CommonUtils.GuideStepBiEvent(Cfg.Id, 0); // BI打点
if (isComplete)
Complete();
}
///
/// 跳过当前步骤
///
public void SkipStep()
{
}
///
/// 完成引导
///
protected void Complete()
{
if (!IsGuiding)
return;
if (isWaiting)
{
isComplete = true;
return;
}
DebugUtil.Log($"完成id为{Cfg.Id}的引导"); // #00FA9A绿色
guideState = E_GuideState.Complete;
DoBeforeComplete();
RecoverState();
GuideManager.Instance.CompleteStep();
CommonUtils.GuideStepBiEvent(Cfg.Id, 1); // BI打点
CommonUtils.GuideStepBiEvent(Cfg.Id.ToString());
}
///
/// 结束引导
///
public void EndGuide()
{
if (!IsGuiding)
return;
RecoverState();
guideState = E_GuideState.Idle;
}
///
/// 引导开始之前
///
protected virtual async UniTask DoBeforeGuide()
{
InputManager.Instance.IsEnable = false;
await UI_GuideController.Open();
}
///
/// 引导实际开始之前
///
protected virtual void DoRealBeforeGuide()
{
InputManager.Instance.IsEnable = true;
}
///
/// 引导
///
protected virtual void DoGuide()
{
SetGuideState();
}
///
/// 引导完成之前
///
protected virtual void DoBeforeComplete()
{
UIManager.Instance.CloseWindow(UINameConst.UI_Guide);
}
///
/// 设置引导状态
///
protected abstract void SetGuideState();
///
/// 还原状态
///
protected abstract void RecoverState();
///
/// 通过条件完成引导
///
///
///
///
private void OnCompleteByCondition(bool conditionResult, object callBackParam, int reactionID)
{
if (!conditionResult)
return;
ConditionReactor.Instance.RemoveReaction(reactionID);
Complete();
}
}
///
/// 点击角色
///
internal sealed class ClickCharacterGuide : GuideStepBase
{
public static ClickCharacterGuide Create(DataGuideCfg cfg)
{
return new ClickCharacterGuide(cfg);
}
///
/// 地板索引
///
private readonly int floorIndex;
private ClickCharacterGuide(DataGuideCfg cfg) : base(cfg)
{
if (Cfg.GuideParams.Length <= 0)
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideType},参数数量错误:1.角色id");
if (!int.TryParse(Cfg.GuideParams[0], out int characterId))
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideType},第1个参数类型错误:应该为int类型");
foreach (GameUnit gameUnit in GameUnitManager.instance.infightUnits.unitList)
{
if (Unit.Data.EGameUnitType.Character != gameUnit.gameunitType)
continue;
if (gameUnit is not Character.Character characterUnit)
continue;
if (characterId == characterUnit.ConfigId)
floorIndex = characterUnit.transData.cellIndex;
}
}
protected override async void DoGuide()
{
try
{
base.DoGuide();
await UI_GuideController.OpenByClickFloor(floorIndex, Cfg);
}
catch (Exception e)
{
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
}
}
protected override void SetGuideState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
{
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.Level_0);
}
UIRoot.Instance.IsEnableGraphicRaycasterByGuide(false);
GuideManager.Instance.IsControlFloor = true;
GuideManager.Instance.FloorIndex = floorIndex;
}
protected override void RecoverState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.isInBattle)
{
//if (GuideManager.Instance.IsUseSkillSuccess)
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.DEFAULT_SPEED);
}
UIRoot.Instance.IsEnableGraphicRaycasterByGuide(true);
GuideManager.Instance.IsControlFloor = false;
GuideManager.Instance.FloorIndex = -1;
}
}
///
/// 点击地板
///
internal sealed class ClickFloorGuide : GuideStepBase
{
public static ClickFloorGuide Create(DataGuideCfg cfg)
{
return new ClickFloorGuide(cfg);
}
///
/// 底板索引
///
private readonly int floorIndex;
private ClickFloorGuide(DataGuideCfg cfg) : base(cfg)
{
if (Cfg.GuideParams.Length <= 0)
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideType},参数数量错误:1.地板索引");
if (int.TryParse(Cfg.GuideParams[0], out int index))
floorIndex = index;
else
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideType},第1个参数类型错误:应该为int类型");
}
protected override async void DoGuide()
{
try
{
base.DoGuide();
await UI_GuideController.OpenByClickFloor(floorIndex, Cfg);
}
catch (Exception e)
{
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
}
}
protected override void DoRealBeforeGuide()
{
base.DoRealBeforeGuide();
EventManager.Instance.Register(EventManager.EventName.Guide_ClickFloor, OnSetFightSpeed);
}
protected override void DoBeforeComplete()
{
EventManager.Instance.Unregister(EventManager.EventName.Guide_ClickFloor, OnSetFightSpeed);
base.DoBeforeComplete();
}
protected override void SetGuideState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.Level_0);
UIRoot.Instance.IsEnableGraphicRaycasterByGuide(false);
GuideManager.Instance.IsControlFloor = true;
GuideManager.Instance.FloorIndex = floorIndex;
}
protected override void RecoverState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.isInBattle)
{
if (GuideManager.Instance.IsUseSkillSuccess)
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.DEFAULT_SPEED);
}
UIRoot.Instance.IsEnableGraphicRaycasterByGuide(true);
GuideManager.Instance.IsControlFloor = false;
GuideManager.Instance.FloorIndex = -1;
}
///
/// 设置战斗速度
///
private void OnSetFightSpeed(int cellIndex)
{
if (cellIndex != floorIndex)
return;
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.isInBattle)
{
//if (GuideManager.Instance.IsUseSkillSuccess)
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.DEFAULT_SPEED);
}
}
}
/*
#region 引导点击
///
/// 点击按钮
///
internal sealed class ClickButtonStep : GuideStepBase
{
///
/// UI名
///
private readonly string uiName;
///
/// 按钮路径
///
private readonly string buttonPath;
public ClickButtonStep(DataGuideCfg cfg) : base(cfg)
{
if (Cfg.GuideTypeParams.Length <= 1)
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},参数数量错误:1.UI名,2.按钮路径");
uiName = Cfg.GuideTypeParams[0];
buttonPath = Cfg.GuideTypeParams[1];
}
protected override async void DoGuide()
{
try
{
base.DoGuide();
await UI_GuideController.Open(UI_GuideController.E_GuideArrowType.Button, uiName, buttonPath, Cfg);
}
catch (Exception e)
{
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
GuideManager.Instance.SkipAllGuide();
}
}
protected override void SetGuideState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.Level_0);
}
protected override void RecoverState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.DEFAULT_SPEED);
}
}
///
/// 滑动按钮
///
internal sealed class SliderButtonStep : GuideStepBase
{
///
/// UI名
///
private readonly string uiName;
///
/// 按钮路径
///
private readonly string buttonPath;
///
/// 地板索引
///
private readonly int floorIndex;
public SliderButtonStep(DataGuideCfg cfg) : base(cfg)
{
if (Cfg.GuideTypeParams.Length <= 1)
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},参数数量错误:1.UI名,2.按钮路径,3(可选).地板索引");
uiName = Cfg.GuideTypeParams[0];
buttonPath = Cfg.GuideTypeParams[1];
if (Cfg.GuideTypeParams.Length > 2)
{
if (int.TryParse(Cfg.GuideTypeParams[2], out int index))
floorIndex = index;
else
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},第3个参数类型错误:应该为int类型");
}
}
protected override async void DoGuide()
{
try
{
base.DoGuide();
await UI_GuideController.Open(UI_GuideController.E_GuideArrowType.SliderButton, uiName, buttonPath, Cfg,
floorIndex);
}
catch (Exception e)
{
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
}
}
protected override void SetGuideState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.Level_0);
}
protected override void RecoverState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.DEFAULT_SPEED);
}
}
///
/// 点击地板
///
internal sealed class ClickFloorStep : GuideStepBase
{
///
/// 底板索引
///
private readonly int floorIndex;
public ClickFloorStep(DataGuideCfg cfg) : base(cfg)
{
if (Cfg.GuideTypeParams.Length <= 0)
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},参数数量错误:1.地板索引");
if (int.TryParse(Cfg.GuideTypeParams[0], out int index))
floorIndex = index;
else
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},第1个参数类型错误:应该为int类型");
}
protected override async void DoGuide()
{
try
{
base.DoGuide();
await UI_GuideController.Open(floorIndex, Cfg);
}
catch (Exception e)
{
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
}
}
protected override void SetGuideState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.Level_0);
UIRoot.Instance.IsEnableGraphicRaycasterByGuide(false);
GuideManager.Instance.IsControlFloor = true;
GuideManager.Instance.FloorIndex = floorIndex;
}
protected override void RecoverState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.isInBattle)
{
if (GuideManager.Instance.IsUseSkillSuccess)
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.DEFAULT_SPEED);
}
UIRoot.Instance.IsEnableGraphicRaycasterByGuide(true);
GuideManager.Instance.IsControlFloor = false;
GuideManager.Instance.FloorIndex = -1;
}
}
///
/// 指向UI说明
///
internal sealed class NoteStep : GuideStepBase
{
///
/// UI名
///
private readonly string uiName;
///
/// 按钮路径
///
private readonly string buttonPath;
public NoteStep(DataGuideCfg cfg) : base(cfg)
{
if (Cfg.GuideTypeParams.Length > 1)
{
uiName = cfg.GuideTypeParams[0];
buttonPath = cfg.GuideTypeParams[1];
}
}
protected override async void DoGuide()
{
try
{
base.DoGuide();
await UI_GuideController.Open(UI_GuideController.E_GuideArrowType.UI, uiName, buttonPath, Cfg);
}
catch (Exception e)
{
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
}
}
protected override void SetGuideState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.Level_0);
}
protected override void RecoverState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.DEFAULT_SPEED);
}
}
///
/// 滑动按钮上阵
///
internal sealed class SliderButtonBattleStep : GuideStepBase
{
///
/// UI名
///
private readonly string uiName;
///
/// 按钮路径
///
private readonly string buttonPath;
///
/// 地板索引
///
private readonly int floorIndex;
public SliderButtonBattleStep(DataGuideCfg cfg) : base(cfg)
{
if (Cfg.GuideTypeParams.Length <= 1)
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},参数数量错误:1.UI名,2.按钮路径,3(可选).地板索引");
uiName = Cfg.GuideTypeParams[0];
buttonPath = Cfg.GuideTypeParams[1];
if (Cfg.GuideTypeParams.Length > 2)
{
if (int.TryParse(Cfg.GuideTypeParams[2], out int index))
floorIndex = index;
else
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},第3个参数类型错误:应该为int类型");
}
}
protected override async void DoGuide()
{
try
{
base.DoGuide();
await UI_GuideController.Open(UI_GuideController.E_GuideArrowType.SliderButton, uiName, buttonPath, Cfg,
floorIndex);
}
catch (Exception e)
{
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
}
}
protected override void SetGuideState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.Level_0);
GuideManager.Instance.IsControlFloor = true;
GuideManager.Instance.FloorIndex = floorIndex;
EventManager.Instance.Register(EventManager.EventName.Guide_CancelModeFight, OnCancelFightModel);
}
protected override void RecoverState()
{
EventManager.Instance.Unregister(EventManager.EventName.Guide_CancelModeFight, OnCancelFightModel);
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.DEFAULT_SPEED);
GuideManager.Instance.IsControlFloor = false;
GuideManager.Instance.FloorIndex = -1;
}
private async void OnCancelFightModel()
{
await UniTask.Delay(300);
await UI_GuideController.Open(UI_GuideController.E_GuideArrowType.SliderButton, uiName, buttonPath, Cfg, floorIndex);
}
}
///
/// 滑动按钮使用技能
///
internal sealed class SliderButtonUseSkillStep : GuideStepBase
{
///
/// UI名
///
private readonly string uiName;
///
/// 按钮路径
///
private readonly string buttonPath;
///
/// 地板索引
///
private readonly int floorIndex;
public SliderButtonUseSkillStep(DataGuideCfg cfg) : base(cfg)
{
if (Cfg.GuideTypeParams.Length <= 1)
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},参数数量错误:1.UI名,2.按钮路径,3(可选).地板索引");
uiName = Cfg.GuideTypeParams[0];
buttonPath = Cfg.GuideTypeParams[1];
if (Cfg.GuideTypeParams.Length > 2)
{
if (int.TryParse(Cfg.GuideTypeParams[2], out int index))
floorIndex = index;
else
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},第3个参数类型错误:应该为int类型");
}
}
protected override async void DoGuide()
{
try
{
base.DoGuide();
await UI_GuideController.Open(UI_GuideController.E_GuideArrowType.SliderButton, uiName, buttonPath, Cfg,
floorIndex);
}
catch (Exception e)
{
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
}
}
protected override void SetGuideState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.Level_0);
GuideManager.Instance.IsControlFloor = true;
GuideManager.Instance.FloorIndex = floorIndex;
EventManager.Instance.Register(EventManager.EventName.UI_SKILL_CANCEL, OnCancelUseSkill);
}
protected override void RecoverState()
{
EventManager.Instance.Unregister(EventManager.EventName.UI_SKILL_CANCEL, OnCancelUseSkill);
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.DEFAULT_SPEED);
GuideManager.Instance.IsControlFloor = false;
GuideManager.Instance.FloorIndex = -1;
}
private async void OnCancelUseSkill()
{
AreaManager.instance.LogicUpdate(0);
await UniTask.Delay(300);
await UI_GuideController.Open(UI_GuideController.E_GuideArrowType.SliderButton, uiName, buttonPath, Cfg, floorIndex);
}
}
///
/// 滑动按钮使用指挥官技能
///
internal sealed class SliderButtonUsePlayerSkillStep : GuideStepBase
{
///
/// UI名
///
private readonly string uiName;
///
/// 按钮路径
///
private readonly string buttonPath;
///
/// 地板索引
///
private readonly int floorIndex;
public SliderButtonUsePlayerSkillStep(DataGuideCfg cfg) : base(cfg)
{
if (Cfg.GuideTypeParams.Length <= 1)
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},参数数量错误:1.UI名,2.按钮路径,3(可选).地板索引");
uiName = Cfg.GuideTypeParams[0];
buttonPath = Cfg.GuideTypeParams[1];
if (Cfg.GuideTypeParams.Length > 2)
{
if (int.TryParse(Cfg.GuideTypeParams[2], out int index))
floorIndex = index;
else
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},第3个参数类型错误:应该为int类型");
}
}
protected override async void DoGuide()
{
try
{
base.DoGuide();
await UI_GuideController.Open(UI_GuideController.E_GuideArrowType.SliderButton, uiName, buttonPath, Cfg,
floorIndex);
}
catch (Exception e)
{
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
}
}
protected override void SetGuideState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.Level_0);
GuideManager.Instance.IsControlFloor = true;
GuideManager.Instance.FloorIndex = floorIndex;
EventManager.Instance.Register(EventManager.EventName.Guide_CancelPlayerSkill, OnCancelUseSkill);
}
protected override void RecoverState()
{
EventManager.Instance.Unregister(EventManager.EventName.Guide_CancelPlayerSkill, OnCancelUseSkill);
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.DEFAULT_SPEED);
GuideManager.Instance.IsControlFloor = false;
GuideManager.Instance.FloorIndex = -1;
}
private async void OnCancelUseSkill()
{
SkillManager.instance.playerSkillManager.LogicUpdate(0);
AreaManager.instance.LogicUpdate(0);
await UniTask.Delay(300);
await UI_GuideController.Open(UI_GuideController.E_GuideArrowType.SliderButton, uiName, buttonPath, Cfg, floorIndex);
}
}
#endregion
///
/// 播放视频
///
internal sealed class PlayVideoStep : GuideStepBase
{
///
/// 视频路径
///
private readonly string videoPath;
public PlayVideoStep(DataGuideCfg cfg) : base(cfg)
{
if (Cfg.GuideTypeParams.Length <= 0)
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},参数数量错误:1.视频路径");
videoPath = Cfg.GuideTypeParams[0];
}
protected override async void DoGuide()
{
try
{
base.DoGuide();
GuideManager.Instance.IsPlayPVVideo = true;
await UI_PVAnimaPlayController.Open(videoPath, () =>
{
GameStateManager.Instance.ChangeState(new GameStateMainScene());
});
Complete();
}
catch (Exception e)
{
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
}
}
protected override void SetGuideState()
{
}
protected override void RecoverState()
{
}
}
///
/// 显示引导提示
///
internal sealed class ShowGuideTipStep : GuideStepBase
{
///
/// 引导提示配置id
///
private readonly int guideTipCfgId;
public ShowGuideTipStep(DataGuideCfg cfg) : base(cfg)
{
if (Cfg.GuideTypeParams.Length <= 0)
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},参数数量错误:1.引导Tip的Id");
if (int.TryParse(Cfg.GuideTypeParams[0], out int id))
guideTipCfgId = id;
else
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},第1个参数类型错误:应该为int类型");
}
protected override async void DoGuide()
{
try
{
base.DoGuide();
await UI_GuideTipController.Open(guideTipCfgId);
}
catch (Exception e)
{
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
}
}
protected override void SetGuideState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.Level_0);
}
protected override void RecoverState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.DEFAULT_SPEED);
}
}
#region 进入流程
///
/// 切换主场景状态
///
internal sealed class EnterMainStateStep : GuideStepBase
{
public EnterMainStateStep(DataGuideCfg cfg) : base(cfg)
{
}
protected override void DoGuide()
{
try
{
base.DoGuide();
GameStateManager.Instance.ChangeState(new GameStateMainScene());
}
catch (Exception e)
{
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
}
}
protected override void SetGuideState()
{
}
protected override void RecoverState()
{
}
}
///
/// 进入关卡
///
internal sealed class EnterLevelStep : GuideStepBase
{
///
/// 关卡id
///
private readonly int levelId;
///
/// 进入故事关卡后是否立即播放
///
private readonly bool isPlay;
public EnterLevelStep(DataGuideCfg cfg) : base(cfg)
{
if (Cfg.GuideTypeParams.Length < 1)
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},参数数量错误:1.关卡id");
if (int.TryParse(Cfg.GuideTypeParams[0], out int id))
levelId = id;
else
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},第1个参数类型错误:应该为int类型");
if (Cfg.GuideTypeParams.Length > 1)
{
if (bool.TryParse(Cfg.GuideTypeParams[1], out bool isPlay))
this.isPlay = isPlay;
else
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},第2个参数类型错误:应该为bool类型");
}
else
isPlay = true;
}
protected override void DoGuide()
{
try
{
base.DoGuide();
LevelManager.Instance.TryEnterLevel(levelId, null, null, isPlay);
}
catch (Exception e)
{
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
GuideManager.Instance.ShowSkipAllGuide();
}
}
protected override void SetGuideState()
{
}
protected override void RecoverState()
{
}
}
///
/// 进入编队
///
internal sealed class EnterEnterEditTeam : GuideStepBase
{
///
/// 关卡id
///
private readonly int levelId;
public EnterEnterEditTeam(DataGuideCfg cfg) : base(cfg)
{
if (Cfg.GuideTypeParams.Length < 1)
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},参数数量错误:1.关卡id");
if (int.TryParse(Cfg.GuideTypeParams[0], out int id))
levelId = id;
else
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},第1个参数类型错误:应该为int类型");
}
protected override void DoGuide()
{
try
{
base.DoGuide();
GameStateManager.Instance.ChangeState(new GameStateMainScene(false, false, async () =>
{
await JumpToManager.JumpFuncAsync(cfg.JumpFuncType.TeamSelect, levelId);
}));
}
catch (Exception e)
{
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
}
}
protected override void SetGuideState()
{
}
protected override void RecoverState()
{
}
}
///
/// 进入队伍信息
///
internal sealed class EnterEnterTeamInfo : GuideStepBase
{
///
/// 关卡id
///
private readonly int levelId;
public EnterEnterTeamInfo(DataGuideCfg cfg) : base(cfg)
{
if (Cfg.GuideTypeParams.Length < 1)
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},参数数量错误:1.关卡id");
if (int.TryParse(Cfg.GuideTypeParams[0], out int id))
levelId = id;
else
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},第1个参数类型错误:应该为int类型");
}
protected override void DoGuide()
{
try
{
base.DoGuide();
GameStateManager.Instance.ChangeState(new GameStateMainScene(false, false, async () =>
{
await JumpToManager.JumpFuncAsync(cfg.JumpFuncType.TeamInfoByGuide, levelId);
}));
}
catch (Exception e)
{
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
}
}
protected override void SetGuideState()
{
}
protected override void RecoverState()
{
}
}
#endregion
///
/// 关卡上阵
///
internal sealed class LevelEmbattleStep : GuideStepBase
{
public LevelEmbattleStep(DataGuideCfg cfg) : base(cfg)
{
}
protected override async UniTask DoBeforeGuide()
{
await base.DoBeforeGuide();
UIWindow uiWindow = UIManager.Instance.GetOpenedWindowByPath(UINameConst.UI_StartBtn_CMSBtn);
if (null == uiWindow)
return;
Transform ts = uiWindow.gameObject.transform.Find("UIStartBtn/Image_UI_Start_BG/Button_StartBtn");
if (null == ts)
return;
Button btn = ts.GetComponent