944 lines
28 KiB
C#
944 lines
28 KiB
C#
using cfg.GuideCfg;
|
||
using System;
|
||
using System.Linq;
|
||
using Cysharp.Threading.Tasks;
|
||
using Gameplay.Level;
|
||
using UnityEngine.UI;
|
||
using UnityEngine;
|
||
using Framework;
|
||
|
||
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.PreparaUseSkillComplete => new FightPreparaUseSkillComplete(Cfg, Complete),
|
||
E_GuideCompleteType.PreparaUsePlayerSkillComplete => new FightPreparaUsePlayerSkillComplete(Cfg,
|
||
Complete),
|
||
E_GuideCompleteType.FightUseSkillComplete => new FightUseSkillComplete(Cfg, Complete),
|
||
E_GuideCompleteType.FightUsePlayerSkillComplete => new FightUsePlayerSkillComplete(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),
|
||
E_GuideCompleteType.WaitEnemyRetreat => new WaitEnemyRetreatComplete(Cfg, Complete),
|
||
E_GuideCompleteType.WaitChangeName => new WaitChangeNameComplete(Cfg, Complete),
|
||
E_GuideCompleteType.WaitEditTeamComplete => new WaitEditTeamComplete(Cfg, Complete),
|
||
E_GuideCompleteType.AnyClickComplete => new AnyClickComplete(Cfg, Complete),
|
||
E_GuideCompleteType.SaveTeamComplete => new SaveTeamComplete(Cfg, Complete),
|
||
E_GuideCompleteType.JoinVehicle => new JoinVehicle(Cfg, Complete),
|
||
_ => throw new Exception($"未处理类型:{Cfg.GuideCompleteType}"),
|
||
};
|
||
}
|
||
|
||
/// <summary>
|
||
/// 开始引导
|
||
/// </summary>
|
||
public async void StartGuide()
|
||
{
|
||
GuideState = E_GuideState.Guiding;
|
||
|
||
DebugUtil.Log($"<color=#00FA9A>开始id为{Cfg.Id}的引导,延迟{Cfg.StepStartDelay}秒开始</color>"); // #00FA9A绿色
|
||
|
||
await DoBeforeGuide();
|
||
|
||
await UniTask.Delay((int)(Cfg.StepStartDelay * 1000f)); // 延迟时间开始
|
||
|
||
DoRealBeforeGuide();
|
||
|
||
DebugUtil.Log($"<color=#00FA9A>实际执行id为{Cfg.Id}的引导</color>"); // #00FA9A绿色
|
||
|
||
DoGuide();
|
||
|
||
CommonUtils.GuideStepBiEvent(Cfg.Id, 0); // BI打点
|
||
}
|
||
|
||
/// <summary>
|
||
/// 跳过当前步骤
|
||
/// </summary>
|
||
public void SkipStep()
|
||
{
|
||
}
|
||
|
||
/// <summary>
|
||
/// 完成引导
|
||
/// </summary>
|
||
protected void Complete()
|
||
{
|
||
if (!IsGuiding)
|
||
return;
|
||
|
||
DebugUtil.Log($"<color=#00FA9A>完成id为{Cfg.Id}的引导</color>"); // #00FA9A绿色
|
||
|
||
GuideState = E_GuideState.Complete;
|
||
DoBeforeComplete();
|
||
RecoverState();
|
||
GuideManager.Instance.CompleteStep(this);
|
||
|
||
CommonUtils.GuideStepBiEvent(Cfg.Id, 1); // BI打点
|
||
CommonUtils.GuideStepBiEvent(Cfg.Id.ToString());
|
||
}
|
||
|
||
/// <summary>
|
||
/// 结束引导
|
||
/// </summary>
|
||
public void EndGuide()
|
||
{
|
||
if (!IsGuiding)
|
||
return;
|
||
|
||
completeBase.RemoveListener();
|
||
RecoverState();
|
||
GuideState = E_GuideState.Idle;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 引导开始之前
|
||
/// </summary>
|
||
protected virtual async UniTask DoBeforeGuide()
|
||
{
|
||
InputManager.Instance.IsEnable = false;
|
||
await UI_GuideController.Open();
|
||
|
||
completeBase.AddListener();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 引导实际开始之前
|
||
/// </summary>
|
||
protected virtual void DoRealBeforeGuide()
|
||
{
|
||
InputManager.Instance.IsEnable = true;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 引导
|
||
/// </summary>
|
||
protected virtual void DoGuide()
|
||
{
|
||
SetGuideState();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 引导完成之前
|
||
/// </summary>
|
||
protected virtual void DoBeforeComplete()
|
||
{
|
||
completeBase.RemoveListener();
|
||
|
||
UIManager.Instance.CloseWindow(UINameConst.UI_Guide);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 设置引导状态
|
||
/// </summary>
|
||
protected abstract void SetGuideState();
|
||
|
||
/// <summary>
|
||
/// 还原状态
|
||
/// </summary>
|
||
protected abstract void RecoverState();
|
||
}
|
||
|
||
#region 引导点击
|
||
|
||
/// <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($"引导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.SetPause(true);
|
||
}
|
||
|
||
protected override void RecoverState()
|
||
{
|
||
if (LevelManager.Instance.IsInLevel && null != LevelManager.Instance.CurrentLevel)
|
||
LevelManager.Instance.CurrentLevel.SetPause(false);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 滑动按钮
|
||
/// </summary>
|
||
internal sealed class SliderButtonStep : GuideStepBase
|
||
{
|
||
/// <summary>
|
||
/// UI名
|
||
/// </summary>
|
||
private readonly string uiName;
|
||
|
||
/// <summary>
|
||
/// 按钮路径
|
||
/// </summary>
|
||
private readonly string buttonPath;
|
||
|
||
/// <summary>
|
||
/// 地板索引
|
||
/// </summary>
|
||
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.SetPause(true);
|
||
}
|
||
|
||
protected override void RecoverState()
|
||
{
|
||
if (LevelManager.Instance.IsInLevel && null != LevelManager.Instance.CurrentLevel)
|
||
LevelManager.Instance.CurrentLevel.SetPause(false);
|
||
}
|
||
}
|
||
|
||
/// <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($"引导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.SetPause(true);
|
||
}
|
||
|
||
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)
|
||
{
|
||
LevelManager.Instance.CurrentLevel.SetPause(false);
|
||
}
|
||
|
||
UIRoot.Instance.IsEnableGraphicRaycasterByGuide(true);
|
||
GuideManager.Instance.IsControlFloor = false;
|
||
GuideManager.Instance.FloorIndex = -1;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 指向UI说明
|
||
/// </summary>
|
||
internal sealed class NoteStep : GuideStepBase
|
||
{
|
||
/// <summary>
|
||
/// UI名
|
||
/// </summary>
|
||
private readonly string uiName;
|
||
|
||
/// <summary>
|
||
/// 按钮路径
|
||
/// </summary>
|
||
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.SetPause(true);
|
||
}
|
||
|
||
protected override void RecoverState()
|
||
{
|
||
if (LevelManager.Instance.IsInLevel && null != LevelManager.Instance.CurrentLevel &&
|
||
LevelManager.Instance.CurrentLevel.isInBattle)
|
||
LevelManager.Instance.CurrentLevel.SetPause(false);
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
/// <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($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},参数数量错误:1.视频路径");
|
||
|
||
videoPath = Cfg.GuideTypeParams[0];
|
||
}
|
||
|
||
protected override async void DoGuide()
|
||
{
|
||
try
|
||
{
|
||
base.DoGuide();
|
||
|
||
UIManager.Instance.CloseWindow(UINameConst.UI_Guide);
|
||
await UI_PlayVideoController.Open(videoPath);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
|
||
}
|
||
}
|
||
|
||
protected override void SetGuideState()
|
||
{
|
||
}
|
||
|
||
protected override void RecoverState()
|
||
{
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 切换主场景状态
|
||
/// </summary>
|
||
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()
|
||
{
|
||
}
|
||
}
|
||
|
||
/// <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($"引导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.SetPause(true);
|
||
}
|
||
|
||
protected override void RecoverState()
|
||
{
|
||
if (LevelManager.Instance.IsInLevel && null != LevelManager.Instance.CurrentLevel &&
|
||
LevelManager.Instance.CurrentLevel.isInBattle)
|
||
LevelManager.Instance.CurrentLevel.SetPause(false);
|
||
}
|
||
}
|
||
|
||
/// <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($"引导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()
|
||
{
|
||
}
|
||
}
|
||
|
||
/// <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()
|
||
{
|
||
try
|
||
{
|
||
base.DoGuide();
|
||
|
||
await UI_GuideController.Open(Cfg, false);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
|
||
}
|
||
}
|
||
|
||
protected override void SetGuideState()
|
||
{
|
||
}
|
||
|
||
protected override void RecoverState()
|
||
{
|
||
}
|
||
}
|
||
|
||
/// <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($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},参数数量错误:1.退出关卡是否切换主场景");
|
||
|
||
if (bool.TryParse(Cfg.GuideTypeParams[0], out bool isContinue))
|
||
this.isContinue = isContinue;
|
||
else
|
||
throw new Exception($"引导id:{Cfg.Id}, 引导类型:{Cfg.GuideStepType},第1个参数类型错误:应该为bool类型");
|
||
}
|
||
|
||
protected override void DoGuide()
|
||
{
|
||
try
|
||
{
|
||
base.DoGuide();
|
||
|
||
UIManager.Instance.CloseWindow(UINameConst.UI_Guide);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
|
||
}
|
||
}
|
||
|
||
protected override void SetGuideState()
|
||
{
|
||
LevelManager.Instance.ExitLevelChangeMainFunc = () => { return isContinue; };
|
||
}
|
||
|
||
protected override void RecoverState()
|
||
{
|
||
LevelManager.Instance.ExitLevelChangeMainFunc = null;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 打开选择角色形象UI
|
||
/// </summary>
|
||
internal sealed class OpenChoosePersonStep : GuideStepBase
|
||
{
|
||
public OpenChoosePersonStep(DataGuideCfg cfg) : base(cfg)
|
||
{
|
||
}
|
||
|
||
protected override async void DoGuide()
|
||
{
|
||
try
|
||
{
|
||
base.DoGuide();
|
||
|
||
await UI_ChoosePersonController.Open();
|
||
await UI_GuideController.Open(Cfg, false);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
|
||
}
|
||
}
|
||
|
||
protected override void SetGuideState()
|
||
{
|
||
}
|
||
|
||
protected override void RecoverState()
|
||
{
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 等待步骤
|
||
/// </summary>
|
||
internal sealed class WaitStep : GuideStepBase
|
||
{
|
||
/// <summary>
|
||
/// 是否有遮罩
|
||
/// </summary>
|
||
private readonly bool isFullMask;
|
||
|
||
public WaitStep(DataGuideCfg cfg) : base(cfg)
|
||
{
|
||
if (Cfg.GuideTypeParams.Length <= 0)
|
||
isFullMask = true;
|
||
else if (bool.TryParse(Cfg.GuideTypeParams[0], out bool isMask))
|
||
isFullMask = isMask;
|
||
else
|
||
isFullMask = false;
|
||
}
|
||
|
||
protected override async void DoGuide()
|
||
{
|
||
try
|
||
{
|
||
base.DoGuide();
|
||
|
||
await UI_GuideController.Open(isFullMask);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
|
||
}
|
||
}
|
||
|
||
protected override void SetGuideState()
|
||
{
|
||
}
|
||
|
||
protected override void RecoverState()
|
||
{
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 等待打开改名事件
|
||
/// </summary>
|
||
internal sealed class WaitOpenChangeName : GuideStepBase
|
||
{
|
||
public WaitOpenChangeName(DataGuideCfg cfg) : base(cfg)
|
||
{
|
||
}
|
||
|
||
protected override async void DoGuide()
|
||
{
|
||
try
|
||
{
|
||
base.DoGuide();
|
||
|
||
await UI_GuideController.Open(false);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
|
||
}
|
||
}
|
||
|
||
protected override void SetGuideState()
|
||
{
|
||
GuideManager.Instance.IsChangeName = false;
|
||
}
|
||
|
||
protected override void RecoverState()
|
||
{
|
||
GuideManager.Instance.IsChangeName = true;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 等待玩家编队
|
||
/// </summary>
|
||
internal sealed class WaitEditTeamStep : GuideStepBase
|
||
{
|
||
public WaitEditTeamStep(DataGuideCfg cfg) : base(cfg)
|
||
{
|
||
}
|
||
|
||
protected override async void DoGuide()
|
||
{
|
||
try
|
||
{
|
||
base.DoGuide();
|
||
|
||
await UI_GuideController.Open(Cfg, false);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
|
||
}
|
||
}
|
||
|
||
protected override void SetGuideState()
|
||
{
|
||
GuideManager.Instance.IsEditTeamGuide = true;
|
||
}
|
||
|
||
protected override void RecoverState()
|
||
{
|
||
GuideManager.Instance.IsEditTeamGuide = false;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 保存默认编队
|
||
/// </summary>
|
||
internal sealed class SaveDefaultTeamStep : GuideStepBase
|
||
{
|
||
public SaveDefaultTeamStep(DataGuideCfg cfg) : base(cfg)
|
||
{
|
||
}
|
||
|
||
protected override void DoGuide()
|
||
{
|
||
try
|
||
{
|
||
base.DoGuide();
|
||
|
||
TeamNew team = TeamEditManagerNew.Instance.GetSelectTeam();
|
||
if (null == team)
|
||
return;
|
||
|
||
uint[] characters = new uint[team.GetCharacterButCommanderIDs().Count];
|
||
|
||
for (int i = 0; i < characters.Length; ++i)
|
||
{
|
||
if (TableManager.Instance.Tables.GlobalConfig.DefaultUnitIDs.Count > i)
|
||
{
|
||
characters[i] = (uint)TableManager.Instance.Tables.GlobalConfig.DefaultUnitIDs[i];
|
||
}
|
||
}
|
||
|
||
var defaultCommander = (uint)TableManager.Instance.Tables.GlobalConfig.DefaultCommander;
|
||
|
||
TeamNew newTeam = new(team.TeamIndex,
|
||
team.Name,
|
||
team.IconNumber,
|
||
defaultCommander,
|
||
characters.ToList(),
|
||
team.GetPlayerSkillIDs());
|
||
|
||
TeamEditManagerNew.Instance.SaveTeam(newTeam);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
DebugUtil.LogError($"引导id:{Cfg.Id},执行错误,异常信息:{e}");
|
||
}
|
||
}
|
||
|
||
protected override void SetGuideState()
|
||
{
|
||
}
|
||
|
||
protected override void RecoverState()
|
||
{
|
||
}
|
||
}
|
||
} |