601 lines
18 KiB
C#
601 lines
18 KiB
C#
using cfg.GuideCfg;
|
|
using System;
|
|
using Cysharp.Threading.Tasks;
|
|
using Gameplay.Level;
|
|
using UnityEngine.UI;
|
|
using UnityEngine;
|
|
|
|
namespace Gameplay.Guide
|
|
{
|
|
/// <summary>
|
|
/// 引导状态
|
|
/// </summary>
|
|
public enum E_GuideState
|
|
{
|
|
/// <summary>
|
|
/// 等待引导
|
|
/// </summary>
|
|
Idle,
|
|
/// <summary>
|
|
/// 引导中
|
|
/// </summary>
|
|
Guiding,
|
|
/// <summary>
|
|
/// 引导完成
|
|
/// </summary>
|
|
Complete,
|
|
}
|
|
|
|
/// <summary>
|
|
/// 引导步骤基类
|
|
/// </summary>
|
|
public abstract class GuideStepBase
|
|
{
|
|
/// <summary>
|
|
/// 引导完成类型
|
|
/// </summary>
|
|
private readonly GuideCompleteBase completeBase;
|
|
|
|
/// <summary>
|
|
/// 引导配置
|
|
/// </summary>
|
|
public DataGuideCfg Cfg { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 引导状态
|
|
/// </summary>
|
|
public E_GuideState GuideState { get; private set; }
|
|
|
|
/// <summary>
|
|
/// 是否引导中
|
|
/// </summary>
|
|
public bool IsGuiding
|
|
{
|
|
get { return E_GuideState.Guiding == GuideState; }
|
|
}
|
|
|
|
public GuideStepBase(DataGuideCfg cfg)
|
|
{
|
|
Cfg = cfg;
|
|
|
|
GuideState = E_GuideState.Idle;
|
|
|
|
completeBase = Cfg.GuideCompleteType switch
|
|
{
|
|
E_GuideCompleteType.PlayVideoOver => new PlayVideoComplete(Cfg, Complete),
|
|
E_GuideCompleteType.OpenUI => new OpenUIComplete(Cfg, Complete),
|
|
E_GuideCompleteType.CloseUI => new CloseUIComplete(Cfg, Complete),
|
|
E_GuideCompleteType.OpenUIAndAnim => new OpenUIAndAnimComplete(Cfg, Complete),
|
|
E_GuideCompleteType.EnterFightLevelComplete => new EnterFightLevelComplete(Cfg, Complete),
|
|
E_GuideCompleteType.EnterStorylineLevelComplete => new EnterStorylineLevelComplete(Cfg, Complete),
|
|
E_GuideCompleteType.EmbattleComplete => new LevelEmbattleComplete(Cfg, Complete),
|
|
E_GuideCompleteType.EmbattleVehicleComplete => new LevelEmbattleComplete(Cfg, Complete),
|
|
E_GuideCompleteType.FightBegin => new FightBeginComplete(Cfg, Complete),
|
|
E_GuideCompleteType.FightMoveBeginComplete => new FightBeginMoveComplete(Cfg, Complete),
|
|
E_GuideCompleteType.FightMoveComplete => new FightMoveComplete(Cfg, Complete),
|
|
E_GuideCompleteType.FightAttackComplete => new FightAttackComplete(Cfg, Complete),
|
|
E_GuideCompleteType.FightEmbattleComplete => new FightEmbattleComplete(Cfg, Complete),
|
|
E_GuideCompleteType.FightMoraleAndRepressionComplete => new FightMoraleAndRepressionComplete(Cfg, Complete),
|
|
E_GuideCompleteType.PreparaUseSkillComplete => new FightPreparaUseSkillComplete(Cfg, Complete),
|
|
E_GuideCompleteType.FightUseSkillComplete => new FightUseSkillComplete(Cfg, Complete),
|
|
E_GuideCompleteType.LevelComplete => new LevelComplete(Cfg, Complete),
|
|
E_GuideCompleteType.ClickGuideButton => new ClickGuideButtonComplete(Cfg, Complete),
|
|
E_GuideCompleteType.ClickFloorComplete => new ClickGuideFloorComplete(cfg, Complete),
|
|
E_GuideCompleteType.FightStartButtonShowComplete => new WaitFightStartButtonShowComplete(cfg, Complete),
|
|
E_GuideCompleteType.WaitPreparatShowComplete => new WaitPreparatShowComplete(cfg, Complete),
|
|
_ => throw new Exception($"未处理类型:{Cfg.GuideCompleteType}"),
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 开始引导
|
|
/// </summary>
|
|
public async void StartGuide()
|
|
{
|
|
DebugUtil.Log($"<color=#00FA9A>开始id为{Cfg.Id}的引导,延迟{Cfg.StepStartDelay}秒开始</color>"); // #00FA9A绿色
|
|
|
|
await DoBeforeGuide();
|
|
|
|
GuideState = E_GuideState.Guiding;
|
|
|
|
await UniTask.Delay((int)(Cfg.StepStartDelay * 1000f)); // 延迟时间开始
|
|
|
|
DebugUtil.Log($"<color=#00FA9A>实际执行id为{Cfg.Id}的引导</color>"); // #00FA9A绿色
|
|
|
|
DoGuide();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 完成引导
|
|
/// </summary>
|
|
public void Complete()
|
|
{
|
|
if (!IsGuiding)
|
|
return;
|
|
|
|
DebugUtil.Log($"<color=#00FA9A>完成id为{Cfg.Id}的引导</color>"); // #00FA9A绿色
|
|
|
|
GuideState = E_GuideState.Complete;
|
|
DoBeforeComplete();
|
|
GuideManager.Instance.CompleteStep(this);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 结束引导
|
|
/// </summary>
|
|
public void EndGuide()
|
|
{
|
|
if (!IsGuiding)
|
|
return;
|
|
|
|
completeBase.RemoveListener();
|
|
|
|
GuideState = E_GuideState.Idle;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 引导开始之前
|
|
/// </summary>
|
|
protected virtual async UniTask DoBeforeGuide()
|
|
{
|
|
await UI_GuideController.Open();
|
|
|
|
completeBase.AddListener();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 引导
|
|
/// </summary>
|
|
protected abstract void DoGuide();
|
|
|
|
/// <summary>
|
|
/// 引导完成之前
|
|
/// </summary>
|
|
protected virtual void DoBeforeComplete()
|
|
{
|
|
completeBase.RemoveListener();
|
|
|
|
UIManager.Instance.CloseWindow(UINameConst.UI_Guide);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击按钮
|
|
/// </summary>
|
|
internal sealed class ClickButtonStep : GuideStepBase
|
|
{
|
|
/// <summary>
|
|
/// UI名
|
|
/// </summary>
|
|
private readonly string uiName;
|
|
/// <summary>
|
|
/// 按钮路径
|
|
/// </summary>
|
|
private readonly string buttonPath;
|
|
|
|
public ClickButtonStep(DataGuideCfg cfg) : base(cfg)
|
|
{
|
|
if (cfg.GuideTypeParams.Length <= 1)
|
|
throw new Exception($"引导类型:{Cfg.GuideStepType},参数错误");
|
|
|
|
uiName = cfg.GuideTypeParams[0];
|
|
buttonPath = cfg.GuideTypeParams[1];
|
|
}
|
|
|
|
protected override async void DoGuide()
|
|
{
|
|
if (LevelManager.Instance.IsInLevel &&
|
|
null != LevelManager.Instance.CurrentLevel)
|
|
{
|
|
LevelManager.Instance.CurrentLevel.SetPause(true);
|
|
}
|
|
|
|
await UI_GuideController.Open(UI_GuideController.E_GuideArrowType.Button, uiName, buttonPath, Cfg);
|
|
}
|
|
}
|
|
|
|
internal sealed class SliderButtonStep : GuideStepBase
|
|
{
|
|
/// <summary>
|
|
/// UI名
|
|
/// </summary>
|
|
private readonly string uiName;
|
|
/// <summary>
|
|
/// 按钮路径
|
|
/// </summary>
|
|
private readonly string buttonPath;
|
|
|
|
public SliderButtonStep(DataGuideCfg cfg) : base(cfg)
|
|
{
|
|
if (cfg.GuideTypeParams.Length <= 1)
|
|
throw new Exception($"引导类型:{Cfg.GuideStepType},参数错误");
|
|
|
|
uiName = cfg.GuideTypeParams[0];
|
|
buttonPath = cfg.GuideTypeParams[1];
|
|
}
|
|
|
|
protected override async void DoGuide()
|
|
{
|
|
if (LevelManager.Instance.IsInLevel &&
|
|
null != LevelManager.Instance.CurrentLevel)
|
|
{
|
|
LevelManager.Instance.CurrentLevel.SetPause(true);
|
|
}
|
|
|
|
await UI_GuideController.Open(UI_GuideController.E_GuideArrowType.SliderButton, uiName, buttonPath, Cfg);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 点击地板按钮
|
|
/// </summary>
|
|
internal sealed class ClickFloorStep : GuideStepBase
|
|
{
|
|
/// <summary>
|
|
/// 底板索引
|
|
/// </summary>
|
|
private readonly int floorIndex;
|
|
|
|
public ClickFloorStep(DataGuideCfg cfg) : base(cfg)
|
|
{
|
|
if (cfg.GuideTypeParams.Length <= 0)
|
|
throw new Exception($"引导类型:{Cfg.GuideStepType},参数错误");
|
|
|
|
if (int.TryParse(cfg.GuideTypeParams[0], out int index))
|
|
floorIndex = index;
|
|
}
|
|
|
|
protected override async void DoGuide()
|
|
{
|
|
GuideManager.Instance.FloorIndex = floorIndex;
|
|
await UI_GuideController.Open(floorIndex, Cfg);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 播放视频
|
|
/// </summary>
|
|
internal sealed class PlayVideoStep : GuideStepBase
|
|
{
|
|
/// <summary>
|
|
/// 视频路径
|
|
/// </summary>
|
|
private readonly string videoPath;
|
|
|
|
public PlayVideoStep(DataGuideCfg cfg) : base(cfg)
|
|
{
|
|
if (cfg.GuideTypeParams.Length <= 0)
|
|
throw new Exception($"引导类型:{Cfg.GuideStepType},参数错误");
|
|
|
|
videoPath = cfg.GuideTypeParams[0];
|
|
}
|
|
|
|
protected override async void DoGuide()
|
|
{
|
|
UIManager.Instance.CloseWindow(UINameConst.UI_Guide);
|
|
await UI_PlayVideoController.Open(videoPath);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 切换主场景状态
|
|
/// </summary>
|
|
internal sealed class EnterMainStateStep : GuideStepBase
|
|
{
|
|
public EnterMainStateStep(DataGuideCfg cfg) : base(cfg)
|
|
{
|
|
}
|
|
|
|
protected override void DoGuide()
|
|
{
|
|
GameStateManager.Instance.ChangeState(new GameStateMainScene());
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 显示引导提示
|
|
/// </summary>
|
|
internal sealed class ShowGuideTipStep : GuideStepBase
|
|
{
|
|
/// <summary>
|
|
/// 引导提示配置id
|
|
/// </summary>
|
|
private readonly int guideTipCfgId;
|
|
|
|
public ShowGuideTipStep(DataGuideCfg cfg) : base(cfg)
|
|
{
|
|
if (cfg.GuideTypeParams.Length <= 0)
|
|
throw new Exception($"引导类型:{Cfg.GuideStepType},参数错误");
|
|
|
|
if (int.TryParse(cfg.GuideTypeParams[0], out int id))
|
|
guideTipCfgId = id;
|
|
}
|
|
|
|
protected override async void DoGuide()
|
|
{
|
|
await UI_GuideTipController.Open(guideTipCfgId);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 进入关卡
|
|
/// </summary>
|
|
internal sealed class EnterLevelStep : GuideStepBase
|
|
{
|
|
/// <summary>
|
|
/// 关卡id
|
|
/// </summary>
|
|
private readonly int levelId;
|
|
/// <summary>
|
|
/// 进入故事关卡后是否立即播放
|
|
/// </summary>
|
|
private readonly bool isPlay;
|
|
|
|
public EnterLevelStep(DataGuideCfg cfg) : base(cfg)
|
|
{
|
|
if (Cfg.GuideTypeParams.Length < 1)
|
|
throw new Exception($"引导类型:{Cfg.GuideStepType},参数错误");
|
|
|
|
if (int.TryParse(Cfg.GuideTypeParams[0], out int id))
|
|
levelId = id;
|
|
|
|
if (Cfg.GuideTypeParams.Length > 1 && bool.TryParse(Cfg.GuideTypeParams[1], out bool isPlay))
|
|
this.isPlay = isPlay;
|
|
else
|
|
this.isPlay = true;
|
|
}
|
|
|
|
protected override void DoGuide()
|
|
{
|
|
LevelManager.Instance.TryEnterLevel(levelId, null, null, isPlay);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关卡上阵
|
|
/// </summary>
|
|
internal sealed class LevelEmbattleStep : GuideStepBase
|
|
{
|
|
public LevelEmbattleStep(DataGuideCfg cfg) : base(cfg)
|
|
{
|
|
|
|
}
|
|
|
|
protected override async UniTask DoBeforeGuide()
|
|
{
|
|
await base.DoBeforeGuide();
|
|
|
|
UIWindow uiWindow = UIManager.Instance.GetOpenedWindowByPath<UIWindow>(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<Button>();
|
|
if (null == btn)
|
|
return;
|
|
|
|
btn.interactable = false;
|
|
}
|
|
|
|
protected override void DoBeforeComplete()
|
|
{
|
|
base.DoBeforeComplete();
|
|
|
|
UIWindow uiWindow = UIManager.Instance.GetOpenedWindowByPath<UIWindow>(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<Button>();
|
|
if (null == btn)
|
|
return;
|
|
|
|
btn.interactable = true;
|
|
}
|
|
|
|
protected override async void DoGuide()
|
|
{
|
|
await UI_GuideController.Open(Cfg, false);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 教学战斗移动
|
|
/// </summary>
|
|
internal sealed class TeachFightMoveStep : GuideStepBase
|
|
{
|
|
/// <summary>
|
|
/// 引导提示配置id
|
|
/// </summary>
|
|
private readonly int guideTipCfgId;
|
|
|
|
public TeachFightMoveStep(DataGuideCfg cfg) : base(cfg)
|
|
{
|
|
if (cfg.GuideTypeParams.Length <= 0)
|
|
throw new Exception($"引导类型:{Cfg.GuideStepType},参数错误");
|
|
|
|
if (int.TryParse(cfg.GuideTypeParams[0], out int id))
|
|
guideTipCfgId = id;
|
|
}
|
|
|
|
protected override async void DoGuide()
|
|
{
|
|
await UI_GuideController.Open(Cfg, false);
|
|
LevelManager.Instance.CurrentLevel.SetPause(true);
|
|
await UI_GuideTipController.Open(guideTipCfgId);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 教学战斗攻击
|
|
/// </summary>
|
|
internal sealed class TeachFightAttackStep : GuideStepBase
|
|
{
|
|
/// <summary>
|
|
/// 引导提示配置id
|
|
/// </summary>
|
|
private readonly int guideTipCfgId;
|
|
|
|
public TeachFightAttackStep(DataGuideCfg cfg) : base(cfg)
|
|
{
|
|
if (cfg.GuideTypeParams.Length <= 0)
|
|
throw new Exception($"引导类型:{Cfg.GuideStepType},参数错误");
|
|
|
|
if (int.TryParse(cfg.GuideTypeParams[0], out int id))
|
|
guideTipCfgId = id;
|
|
}
|
|
|
|
protected override async void DoGuide()
|
|
{
|
|
await UI_GuideController.Open(Cfg, false);
|
|
LevelManager.Instance.CurrentLevel.SetPause(true);
|
|
await UI_GuideTipController.Open(guideTipCfgId);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 教学士气与压制
|
|
/// </summary>
|
|
internal sealed class TeachMoraleAndRepression : GuideStepBase
|
|
{
|
|
/// <summary>
|
|
/// 引导提示配置id
|
|
/// </summary>
|
|
private readonly int guideTipCfgId;
|
|
|
|
public TeachMoraleAndRepression(DataGuideCfg cfg) : base(cfg)
|
|
{
|
|
if (cfg.GuideTypeParams.Length <= 0)
|
|
throw new Exception($"引导类型:{Cfg.GuideStepType},参数错误");
|
|
|
|
if (int.TryParse(cfg.GuideTypeParams[0], out int id))
|
|
guideTipCfgId = id;
|
|
}
|
|
|
|
protected override async void DoGuide()
|
|
{
|
|
await UI_GuideController.Open(Cfg, false);
|
|
LevelManager.Instance.CurrentLevel.SetPause(true);
|
|
await UI_GuideTipController.Open(guideTipCfgId);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 教学使用技能
|
|
/// </summary>
|
|
internal sealed class TeachUseSkill : GuideStepBase
|
|
{
|
|
public TeachUseSkill(DataGuideCfg cfg) : base(cfg)
|
|
{
|
|
}
|
|
|
|
protected override async void DoGuide()
|
|
{
|
|
await UI_GuideController.Open(Cfg, false);
|
|
LevelManager.Instance.CurrentLevel.SetPause(true);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 教学战斗中上阵
|
|
/// </summary>
|
|
internal sealed class TeachFightEmbattle : GuideStepBase
|
|
{
|
|
/// <summary>
|
|
/// 引导提示配置id
|
|
/// </summary>
|
|
private readonly int guideTipCfgId;
|
|
|
|
public TeachFightEmbattle(DataGuideCfg cfg) : base(cfg)
|
|
{
|
|
if (cfg.GuideTypeParams.Length <= 0)
|
|
throw new Exception($"引导类型:{Cfg.GuideStepType},参数错误");
|
|
|
|
if (int.TryParse(cfg.GuideTypeParams[0], out int id))
|
|
guideTipCfgId = id;
|
|
}
|
|
|
|
protected override async void DoGuide()
|
|
{
|
|
await UI_GuideController.Open(Cfg, false);
|
|
LevelManager.Instance.CurrentLevel.SetPause(true);
|
|
await UI_GuideTipController.Open(guideTipCfgId);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 等待关卡结束
|
|
/// </summary>
|
|
internal sealed class WaitLevelOver : GuideStepBase
|
|
{
|
|
private readonly bool isContinue;
|
|
|
|
public WaitLevelOver(DataGuideCfg cfg) : base(cfg)
|
|
{
|
|
if (cfg.GuideTypeParams.Length <= 0)
|
|
throw new Exception($"引导类型:{Cfg.GuideStepType},参数错误");
|
|
|
|
if (bool.TryParse(cfg.GuideTypeParams[0], out bool isContinue))
|
|
this.isContinue = isContinue;
|
|
}
|
|
|
|
protected override void DoGuide()
|
|
{
|
|
UIManager.Instance.CloseWindow(UINameConst.UI_Guide);
|
|
LevelManager.Instance.ExitLevelChangeMainFunc = () => { return isContinue; };
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 关卡载具上阵
|
|
/// </summary>
|
|
internal sealed class LevelVehicleEmbattleStep : GuideStepBase
|
|
{
|
|
public LevelVehicleEmbattleStep(DataGuideCfg cfg) : base(cfg)
|
|
{
|
|
|
|
}
|
|
|
|
protected override void DoGuide()
|
|
{
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 打开选择角色形象UI
|
|
/// </summary>
|
|
internal sealed class OpenChoosePersonStep : GuideStepBase
|
|
{
|
|
public OpenChoosePersonStep(DataGuideCfg cfg) : base(cfg)
|
|
{
|
|
}
|
|
|
|
protected override async void DoGuide()
|
|
{
|
|
await UI_ChoosePersonController.Open();
|
|
await UI_GuideController.Open(Cfg, false);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 等待步骤
|
|
/// </summary>
|
|
internal sealed class WaitStep : GuideStepBase
|
|
{
|
|
public WaitStep(DataGuideCfg cfg) : base(cfg)
|
|
{
|
|
}
|
|
|
|
protected override void DoGuide()
|
|
{
|
|
|
|
}
|
|
}
|
|
} |