NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Guide/GuideStep.cs

1094 lines
33 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using cfg.GuideCfg;
using System;
using Cysharp.Threading.Tasks;
using Gameplay.Level;
using Framework;
using Gameplay.Unit;
using Framework.Condition;
namespace Gameplay.Guide
{
/// <summary>
/// 引导步骤基类
/// </summary>
public abstract class GuideStepBase
{
/// <summary>
/// 是否等待中
/// </summary>
private bool isWaiting;
/// <summary>
/// 完成标记
/// </summary>
private bool isComplete;
/// <summary>
/// 引导状态
/// </summary>
private E_GuideState guideState;
/// <summary>
/// 引导配置
/// </summary>
public DataGuideCfg Cfg { get; private set; }
/// <summary>
/// 是否引导中
/// </summary>
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);
}
/// <summary>
/// 开始引导
/// </summary>
public async void StartGuide()
{
guideState = E_GuideState.Guiding;
isWaiting = true;
GuideManager.Debug($"开始id为{Cfg.Id}的引导,延迟{Cfg.StepStartDelay}秒开始");
await DoBeforeGuide();
await UniTask.WaitForSeconds(Cfg.StepStartDelay); // 延迟时间开始
isWaiting = false;
DoRealBeforeGuide();
GuideManager.Debug($"实际执行id为{Cfg.Id}的引导");
DoGuide();
CommonUtils.GuideStepBiEvent(Cfg.Id, 0); // BI打点
if (isComplete)
Complete();
}
/// <summary>
/// 跳过当前步骤
/// </summary>
public void SkipStep()
{
}
/// <summary>
/// 结束引导
/// </summary>
public void EndGuide()
{
if (!IsGuiding)
return;
RecoverState();
guideState = E_GuideState.Idle;
}
/// <summary>
/// 引导开始之前
/// </summary>
protected virtual async UniTask DoBeforeGuide()
{
await UI_GuideController.Open();
UIManager.Instance.IsEnableBack = false;
InputManager.Instance.IsEnable = false;
}
/// <summary>
/// 引导实际开始之前
/// </summary>
protected virtual void DoRealBeforeGuide()
{
InputManager.Instance.IsEnable = true;
}
/// <summary>
/// 引导
/// </summary>
protected virtual void DoGuide()
{
SetGuideState();
}
/// <summary>
/// 引导完成之前
/// </summary>
protected virtual void DoBeforeComplete()
{
UIManager.Instance.CloseWindow(UINameConst.UI_Guide);
UIManager.Instance.IsEnableBack = true;
}
/// <summary>
/// 设置引导状态
/// </summary>
protected virtual void SetGuideState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
{
if (UIManager.Instance.CheckWindowCreated(UINameConst.UIFightInfoTip))
UIManager.Instance.CloseWindow(UINameConst.UIFightInfoTip, UIWindowCloseType.OnlyHide);
PVEManager.Instance.EnableSelfAutoFight(false);
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.Level_0); // 引导中战斗速度设为0
}
}
/// <summary>
/// 还原状态
/// </summary>
protected virtual void RecoverState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
{
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.DEFAULT_SPEED); // 引导完成,战斗速度还原
}
}
/// <summary>
/// 完成引导
/// </summary>
private void Complete()
{
if (!IsGuiding)
{
isComplete = true;
return;
}
if (isWaiting)
{
isComplete = true;
return;
}
GuideManager.Debug($"完成id为{Cfg.Id}的引导");
guideState = E_GuideState.Complete;
DoBeforeComplete();
RecoverState();
GuideManager.Instance.CompleteStep();
CommonUtils.GuideStepBiEvent(Cfg.Id, 1); // BI打点
CommonUtils.GuideStepBiEvent(Cfg.Id.ToString());
}
/// <summary>
/// 通过条件完成引导
/// </summary>
/// <param name="conditionResult"></param>
/// <param name="callBackParam"></param>
/// <param name="reactionID"></param>
private void OnCompleteByCondition(bool conditionResult, object callBackParam, int reactionID)
{
if (!conditionResult)
return;
ConditionReactor.Instance.RemoveReaction(reactionID);
Complete();
}
}
/// <summary>
/// 点击地板
/// </summary>
internal sealed class ClickFloorGuide : GuideStepBase
{
public static ClickFloorGuide Create(DataGuideCfg cfg)
{
return new ClickFloorGuide(cfg);
}
/// <summary>
/// 底板索引
/// </summary>
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<int>(EventManager.EventName.Guide_ClickFloor, OnSetFightSpeed);
EventManager.Instance.Register<int>(EventManager.EventName.Guide_ClickFloor, OnClickFloor);
}
protected override void DoBeforeComplete()
{
EventManager.Instance.Unregister<int>(EventManager.EventName.Guide_ClickFloor, OnClickFloor);
EventManager.Instance.Unregister<int>(EventManager.EventName.Guide_ClickFloor, OnSetFightSpeed);
base.DoBeforeComplete();
}
protected override void SetGuideState()
{
base.SetGuideState();
UIRoot.Instance.IsEnableGraphicRaycasterByGuide(false);
GuideManager.Instance.IsControlFloor = true;
GuideManager.Instance.FloorIndex = floorIndex;
}
protected override void RecoverState()
{
UIRoot.Instance.IsEnableGraphicRaycasterByGuide(true);
GuideManager.Instance.IsControlFloor = false;
GuideManager.Instance.FloorIndex = -1;
base.RecoverState();
}
/// <summary>
/// 设置战斗速度
/// </summary>
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);
}
}
private async void OnClickFloor(int cellIndex)
{
if (cellIndex != floorIndex)
return;
await UI_GuideController.Open();
}
}
/// <summary>
/// 点击角色
/// </summary>
internal sealed class ClickCharacterGuide : GuideStepBase
{
public static ClickCharacterGuide Create(DataGuideCfg cfg)
{
return new ClickCharacterGuide(cfg);
}
/// <summary>
/// 角色id
/// </summary>
private readonly int characterId;
/// <summary>
/// 地板索引
/// </summary>
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 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 DoRealBeforeGuide()
{
base.DoRealBeforeGuide();
EventManager.Instance.Register<int>(EventManager.EventName.Guide_UseSkillPre, OnSetFightSpeed);
}
protected override void DoBeforeComplete()
{
EventManager.Instance.Unregister<int>(EventManager.EventName.Guide_UseSkillPre, OnSetFightSpeed);
base.DoBeforeComplete();
}
protected override void SetGuideState()
{
base.SetGuideState();
UIRoot.Instance.IsEnableGraphicRaycasterByGuide(false);
GuideManager.Instance.IsControlFloor = true;
GuideManager.Instance.FloorIndex = floorIndex;
}
protected override void RecoverState()
{
UIRoot.Instance.IsEnableGraphicRaycasterByGuide(true);
GuideManager.Instance.IsControlFloor = false;
GuideManager.Instance.FloorIndex = -1;
base.RecoverState();
}
/// <summary>
/// 设置战斗速度
/// </summary>
/// <param name="characterId"></param>
private void OnSetFightSpeed(int id)
{
if (characterId != id)
return;
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.isInBattle)
{
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.DEFAULT_SPEED);
}
}
}
/// <summary>
/// 点击敌人
/// </summary>
internal sealed class ClickEnemyGuide : GuideStepBase
{
public static ClickEnemyGuide Create(DataGuideCfg cfg)
{
return new ClickEnemyGuide(cfg);
}
/// <summary>
/// 地板索引
/// </summary>
private readonly int floorIndex;
private ClickEnemyGuide(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 enemyId))
throw new Exception($"引导id{Cfg.Id}, 引导类型:{Cfg.GuideType}第1个参数类型错误应该为int类型");
foreach (GameUnit gameUnit in GameUnitManager.instance.infightUnits.unitList)
{
if (enemyId == gameUnit.GetID())
floorIndex = gameUnit.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()
{
base.SetGuideState();
UIRoot.Instance.IsEnableGraphicRaycasterByGuide(false);
GuideManager.Instance.IsControlFloor = true;
GuideManager.Instance.FloorIndex = floorIndex;
}
protected override void RecoverState()
{
UIRoot.Instance.IsEnableGraphicRaycasterByGuide(true);
GuideManager.Instance.IsControlFloor = false;
GuideManager.Instance.FloorIndex = -1;
base.RecoverState();
}
}
/// <summary>
/// 指向UI说明
/// </summary>
internal sealed class ArrowUITipGuide : GuideStepBase
{
public static ArrowUITipGuide Create(DataGuideCfg cfg)
{
return new ArrowUITipGuide(cfg);
}
/// <summary>
/// UI名
/// </summary>
private readonly string uiName;
/// <summary>
/// 按钮路径
/// </summary>
private readonly string buttonPath;
public ArrowUITipGuide(DataGuideCfg cfg) : base(cfg)
{
if (Cfg.GuideParams.Length > 1)
{
uiName = cfg.GuideParams[0];
buttonPath = cfg.GuideParams[1];
}
}
protected override async void DoGuide()
{
try
{
base.DoGuide();
await UI_GuideController.OpenByArrowUITip(uiName, buttonPath, Cfg);
}
catch (Exception e)
{
DebugUtil.LogError($"引导id{Cfg.Id},执行错误,异常信息:{e}");
}
}
}
/// <summary>
/// 点击引导按钮
/// </summary>
internal sealed class ClickButtonGuide : GuideStepBase
{
public static ClickButtonGuide Create(DataGuideCfg cfg)
{
return new ClickButtonGuide(cfg);
}
/// <summary>
/// UI名
/// </summary>
private readonly string uiName;
/// <summary>
/// 按钮路径
/// </summary>
private readonly string buttonPath;
public ClickButtonGuide(DataGuideCfg cfg) : base(cfg)
{
if (Cfg.GuideParams.Length < 2)
throw new Exception($"引导id{Cfg.Id}, 引导类型:{Cfg.GuideType}参数数量错误1.UI名2.按钮路径");
uiName = Cfg.GuideParams[0];
buttonPath = Cfg.GuideParams[1];
}
protected override async void DoGuide()
{
try
{
base.DoGuide();
await UI_GuideController.OpenByButton(uiName, buttonPath, Cfg);
}
catch (Exception e)
{
DebugUtil.LogError($"引导id{Cfg.Id},执行错误,异常信息:{e}");
}
}
}
/// <summary>
/// 关卡取消选中单位
/// </summary>
internal sealed class LevelCancelSelectUnitGuide : GuideStepBase
{
public static LevelCancelSelectUnitGuide Create(DataGuideCfg cfg)
{
return new LevelCancelSelectUnitGuide(cfg);
}
public LevelCancelSelectUnitGuide(DataGuideCfg cfg) : base(cfg)
{
}
protected override void DoGuide()
{
try
{
base.DoGuide();
if (null != LevelManager.Instance.CurrentLevel.selectUnit)
LevelManager.Instance.CurrentLevel.UnSelectUnit();
}
catch (Exception e)
{
DebugUtil.LogError($"引导id{Cfg.Id},执行错误,异常信息:{e}");
}
}
}
/*
#region 引导点击
/// <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.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);
}
}
/// <summary>
/// 滑动按钮上阵
/// </summary>
internal sealed class SliderButtonBattleStep : GuideStepBase
{
/// <summary>
/// UI名
/// </summary>
private readonly string uiName;
/// <summary>
/// 按钮路径
/// </summary>
private readonly string buttonPath;
/// <summary>
/// 地板索引
/// </summary>
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);
}
}
/// <summary>
/// 滑动按钮使用技能
/// </summary>
internal sealed class SliderButtonUseSkillStep : GuideStepBase
{
/// <summary>
/// UI名
/// </summary>
private readonly string uiName;
/// <summary>
/// 按钮路径
/// </summary>
private readonly string buttonPath;
/// <summary>
/// 地板索引
/// </summary>
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);
}
}
/// <summary>
/// 滑动按钮使用指挥官技能
/// </summary>
internal sealed class SliderButtonUsePlayerSkillStep : GuideStepBase
{
/// <summary>
/// UI名
/// </summary>
private readonly string uiName;
/// <summary>
/// 按钮路径
/// </summary>
private readonly string buttonPath;
/// <summary>
/// 地板索引
/// </summary>
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
/// <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.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);
}
}
/// <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()
{
}
}
#region 编队相关
/// <summary>
/// 队伍选择
/// </summary>
internal sealed class SelectTeamStep : GuideStepBase
{
/// <summary>
/// 选择的队伍索引
/// </summary>
private readonly int teamIndex;
public SelectTeamStep(DataGuideCfg cfg) : base(cfg)
{
if (Cfg.GuideTypeParams.Length < 1)
throw new Exception($"引导id{Cfg.Id}, 引导类型:{Cfg.GuideStepType}参数数量错误1.队伍索引");
if (int.TryParse(Cfg.GuideTypeParams[0], out int index))
teamIndex = index;
else
throw new Exception($"引导id{Cfg.Id}, 引导类型:{Cfg.GuideStepType}第1个参数类型错误应该为int类型");
}
protected override void DoGuide()
{
try
{
base.DoGuide();
TeamEditManager.Instance.SetSelectTeam(teamIndex);
}
catch (Exception e)
{
DebugUtil.LogError($"引导id{Cfg.Id},执行错误,异常信息:{e}");
}
}
protected override void SetGuideState()
{
}
protected override void RecoverState()
{
}
}
#endregion
*/
}