using cfg.GuideCfg; using Framework; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// 引导状态 /// public enum E_GuideState { /// /// 未开始 /// NotStarted, /// /// 引导中 /// Guiding, /// /// 引导完成 /// Complete, } /// /// 引导步骤基类 /// public abstract class GuideStepBase { /// /// 引导步骤类型 /// public string StepType; /// /// 引导状态 /// protected E_GuideState guideState; public GuideStepBase(DataGuideCfg dataGuideCfg) { guideState = E_GuideState.NotStarted; } public void StartGuide() { DoBeforeGuide(); guideState = E_GuideState.Guiding; DoGuide(); } /// /// 完成引导 /// public void Complete() { if (E_GuideState.NotStarted == guideState) return; if (E_GuideState.Complete == guideState) return; guideState = E_GuideState.Complete; DoBeforeComplete(); GuideManager.Instance.Complete(this); } /// /// 引导显示之前 /// protected virtual void DoBeforeGuide() { } /// /// 引导完成之前 /// protected virtual void DoBeforeComplete() { } /// /// 引导 /// protected abstract void DoGuide(); } /// /// 点击按钮 /// public class ClickButtonStep : GuideStepBase { public ClickButtonStep(DataGuideCfg dataGuideCfg) : base(dataGuideCfg) { } protected override void DoGuide() { } } /// /// 播放视频 /// public class PlayVideoStep : GuideStepBase { /// /// 视频路径 /// private readonly string videoPath; public PlayVideoStep(DataGuideCfg cfg) : base(cfg) { if (cfg.GuideTypeParams.Length <= 0) throw new Exception($"引导类型:{StepType}参数错误"); videoPath = cfg.GuideTypeParams[0]; } protected override void DoBeforeGuide() { EventManager.Instance.Register(EventManager.EventName.PlayVideoComplete, (Action)OnPlayVideoComplete); } protected override async void DoGuide() { await UI_PlayVideoController.Open(videoPath); } protected override void DoBeforeComplete() { EventManager.Instance.Unregister(EventManager.EventName.PlayVideoComplete, (Action)OnPlayVideoComplete); } /// /// 播放视频完成回调 /// /// private void OnPlayVideoComplete(string path) { if (path != videoPath) return; Complete(); } }