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

1094 lines
33 KiB
C#
Raw Normal View History

2024-05-22 19:08:14 +08:00
using cfg.GuideCfg;
2024-05-24 15:07:50 +08:00
using System;
2024-05-27 13:32:18 +08:00
using Cysharp.Threading.Tasks;
2024-05-29 16:36:30 +08:00
using Gameplay.Level;
2024-07-05 20:49:03 +08:00
using Framework;
2025-04-08 14:07:20 +08:00
using Gameplay.Unit;
using Framework.Condition;
2024-05-22 19:08:14 +08:00
2024-05-29 16:36:30 +08:00
namespace Gameplay.Guide
2024-05-24 15:07:50 +08:00
{
2024-05-29 13:04:51 +08:00
/// <summary>
2024-05-29 16:36:30 +08:00
/// 引导步骤基类
2024-05-29 13:04:51 +08:00
/// </summary>
2024-05-29 16:36:30 +08:00
public abstract class GuideStepBase
2024-05-29 13:04:51 +08:00
{
2024-05-29 16:36:30 +08:00
/// <summary>
2025-04-08 14:07:20 +08:00
/// 是否等待中
/// </summary>
private bool isWaiting;
/// <summary>
/// 完成标记
2024-05-29 16:36:30 +08:00
/// </summary>
private bool isComplete;
2024-05-29 16:36:30 +08:00
/// <summary>
2025-04-08 14:07:20 +08:00
/// 引导状态
2024-05-29 16:36:30 +08:00
/// </summary>
2025-04-08 14:07:20 +08:00
private E_GuideState guideState;
2024-05-29 16:36:30 +08:00
/// <summary>
2025-04-08 14:07:20 +08:00
/// 引导配置
2024-05-29 16:36:30 +08:00
/// </summary>
2025-04-08 14:07:20 +08:00
public DataGuideCfg Cfg { get; private set; }
2024-05-29 16:36:30 +08:00
/// <summary>
/// 是否引导中
/// </summary>
2025-04-08 14:07:20 +08:00
public bool IsGuiding { get { return E_GuideState.Guiding == guideState; } }
2024-05-29 13:04:51 +08:00
2024-05-29 16:36:30 +08:00
public GuideStepBase(DataGuideCfg cfg)
{
Cfg = cfg;
2025-04-08 14:07:20 +08:00
guideState = E_GuideState.Idle;
isWaiting = true;
isComplete = false;
2024-05-29 16:36:30 +08:00
2025-04-08 14:07:20 +08:00
ConditionReactor.Instance.AddReaction(cfg.CompleteCondition, OnCompleteByCondition);
2024-05-29 16:36:30 +08:00
}
/// <summary>
/// 开始引导
/// </summary>
2025-04-08 14:07:20 +08:00
public async void StartGuide()
2024-05-29 16:36:30 +08:00
{
2025-04-08 14:07:20 +08:00
guideState = E_GuideState.Guiding;
isWaiting = true;
2024-10-11 15:46:57 +08:00
2025-04-08 16:03:25 +08:00
GuideManager.Debug($"开始id为{Cfg.Id}的引导,延迟{Cfg.StepStartDelay}秒开始");
2024-06-04 13:26:59 +08:00
2024-06-04 15:13:16 +08:00
await DoBeforeGuide();
2024-05-29 16:36:30 +08:00
await UniTask.WaitForSeconds(Cfg.StepStartDelay); // 延迟时间开始
2025-04-08 14:07:20 +08:00
isWaiting = false;
DoRealBeforeGuide();
2024-05-29 16:36:30 +08:00
2025-04-08 16:03:25 +08:00
GuideManager.Debug($"实际执行id为{Cfg.Id}的引导");
2024-06-04 13:26:59 +08:00
2024-06-03 19:36:47 +08:00
DoGuide();
2024-09-24 12:45:00 +08:00
2024-09-29 15:47:42 +08:00
CommonUtils.GuideStepBiEvent(Cfg.Id, 0); // BI打点
if (isComplete)
Complete();
2024-05-29 16:36:30 +08:00
}
2024-05-24 15:07:50 +08:00
/// <summary>
/// 跳过当前步骤
/// </summary>
public void SkipStep()
{
}
2024-05-29 16:36:30 +08:00
/// <summary>
/// 结束引导
/// </summary>
public void EndGuide()
{
if (!IsGuiding)
return;
2024-10-11 17:17:54 +08:00
RecoverState();
2025-04-08 14:07:20 +08:00
guideState = E_GuideState.Idle;
2024-05-29 16:36:30 +08:00
}
2024-06-03 19:36:47 +08:00
/// <summary>
/// 引导开始之前
/// </summary>
2024-06-04 15:13:16 +08:00
protected virtual async UniTask DoBeforeGuide()
2024-06-03 19:36:47 +08:00
{
await UI_GuideController.Open();
2025-04-08 14:15:34 +08:00
UIManager.Instance.IsEnableBack = false;
InputManager.Instance.IsEnable = false;
2024-06-03 19:36:47 +08:00
}
/// <summary>
/// 引导实际开始之前
/// </summary>
protected virtual void DoRealBeforeGuide()
{
InputManager.Instance.IsEnable = true;
}
2024-06-03 19:36:47 +08:00
/// <summary>
/// 引导
/// </summary>
protected virtual void DoGuide()
{
SetGuideState();
}
2024-06-03 19:36:47 +08:00
/// <summary>
/// 引导完成之前
/// </summary>
protected virtual void DoBeforeComplete()
{
2024-06-04 15:13:16 +08:00
UIManager.Instance.CloseWindow(UINameConst.UI_Guide);
2025-04-08 14:15:34 +08:00
UIManager.Instance.IsEnableBack = true;
2024-06-03 19:36:47 +08:00
}
/// <summary>
/// 设置引导状态
/// </summary>
2025-04-08 19:05:57 +08:00
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);
2025-04-08 19:05:57 +08:00
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.Level_0); // 引导中战斗速度设为0
}
}
/// <summary>
/// 还原状态
/// </summary>
2025-04-08 19:05:57 +08:00
protected virtual void RecoverState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
{
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.DEFAULT_SPEED); // 引导完成,战斗速度还原
}
}
2025-04-08 14:07:20 +08:00
2025-04-08 16:03:25 +08:00
/// <summary>
/// 完成引导
/// </summary>
private void Complete()
{
if (!IsGuiding)
{
isComplete = true;
2025-04-08 16:03:25 +08:00
return;
}
2025-04-08 16:03:25 +08:00
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());
}
2025-04-08 14:07:20 +08:00
/// <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();
}
2024-05-22 19:08:14 +08:00
}
2025-04-08 14:07:20 +08:00
/// <summary>
2025-04-08 16:03:25 +08:00
/// 点击地板
2025-04-08 14:07:20 +08:00
/// </summary>
2025-04-08 16:03:25 +08:00
internal sealed class ClickFloorGuide : GuideStepBase
2025-04-08 14:07:20 +08:00
{
2025-04-08 16:03:25 +08:00
public static ClickFloorGuide Create(DataGuideCfg cfg)
2025-04-08 14:07:20 +08:00
{
2025-04-08 16:03:25 +08:00
return new ClickFloorGuide(cfg);
2025-04-08 14:07:20 +08:00
}
/// <summary>
2025-04-08 16:03:25 +08:00
/// 底板索引
2025-04-08 14:07:20 +08:00
/// </summary>
private readonly int floorIndex;
2025-04-08 16:03:25 +08:00
private ClickFloorGuide(DataGuideCfg cfg) : base(cfg)
2025-04-08 14:07:20 +08:00
{
if (Cfg.GuideParams.Length <= 0)
2025-04-08 16:03:25 +08:00
throw new Exception($"引导id{Cfg.Id}, 引导类型:{Cfg.GuideType}参数数量错误1.地板索引");
2025-04-08 14:07:20 +08:00
2025-04-08 16:03:25 +08:00
if (int.TryParse(Cfg.GuideParams[0], out int index))
floorIndex = index;
else
2025-04-08 14:07:20 +08:00
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}");
}
}
2025-04-08 16:03:25 +08:00
protected override void DoRealBeforeGuide()
{
base.DoRealBeforeGuide();
EventManager.Instance.Register<int>(EventManager.EventName.Guide_ClickFloor, OnSetFightSpeed);
2025-04-09 19:39:09 +08:00
EventManager.Instance.Register<int>(EventManager.EventName.Guide_ClickFloor, OnClickFloor);
2025-04-08 16:03:25 +08:00
}
protected override void DoBeforeComplete()
{
2025-04-09 19:39:09 +08:00
EventManager.Instance.Unregister<int>(EventManager.EventName.Guide_ClickFloor, OnClickFloor);
2025-04-08 16:03:25 +08:00
EventManager.Instance.Unregister<int>(EventManager.EventName.Guide_ClickFloor, OnSetFightSpeed);
base.DoBeforeComplete();
}
2025-04-08 14:07:20 +08:00
protected override void SetGuideState()
{
2025-04-08 19:05:57 +08:00
base.SetGuideState();
2025-04-08 14:07:20 +08:00
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;
2025-04-08 19:05:57 +08:00
base.RecoverState();
2025-04-08 14:07:20 +08:00
}
2025-04-08 16:03:25 +08:00
/// <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);
}
}
2025-04-09 19:39:09 +08:00
private async void OnClickFloor(int cellIndex)
{
if (cellIndex != floorIndex)
return;
await UI_GuideController.Open();
}
2025-04-08 14:07:20 +08:00
}
/// <summary>
2025-04-08 16:03:25 +08:00
/// 点击角色
2025-04-08 14:07:20 +08:00
/// </summary>
2025-04-08 16:03:25 +08:00
internal sealed class ClickCharacterGuide : GuideStepBase
2025-04-08 14:07:20 +08:00
{
2025-04-08 16:03:25 +08:00
public static ClickCharacterGuide Create(DataGuideCfg cfg)
2025-04-08 14:07:20 +08:00
{
2025-04-08 16:03:25 +08:00
return new ClickCharacterGuide(cfg);
2025-04-08 14:07:20 +08:00
}
2025-04-09 16:00:50 +08:00
/// <summary>
/// 角色id
/// </summary>
private readonly int characterId;
2025-04-08 14:07:20 +08:00
/// <summary>
2025-04-08 16:03:25 +08:00
/// 地板索引
2025-04-08 14:07:20 +08:00
/// </summary>
private readonly int floorIndex;
2025-04-08 16:03:25 +08:00
private ClickCharacterGuide(DataGuideCfg cfg) : base(cfg)
2025-04-08 14:07:20 +08:00
{
if (Cfg.GuideParams.Length <= 0)
2025-04-08 16:03:25 +08:00
throw new Exception($"引导id{Cfg.Id}, 引导类型:{Cfg.GuideType}参数数量错误1.角色id");
2025-04-08 14:07:20 +08:00
2025-04-09 16:00:50 +08:00
if (!int.TryParse(Cfg.GuideParams[0], out characterId))
2025-04-08 14:07:20 +08:00
throw new Exception($"引导id{Cfg.Id}, 引导类型:{Cfg.GuideType}第1个参数类型错误应该为int类型");
2025-04-08 16:03:25 +08:00
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;
}
2025-04-08 14:07:20 +08:00
}
protected override async void DoGuide()
{
try
{
base.DoGuide();
await UI_GuideController.OpenByClickFloor(floorIndex, Cfg);
}
catch (Exception e)
{
DebugUtil.LogError($"引导id{Cfg.Id},执行错误,异常信息:{e}");
}
}
2025-04-09 16:00:50 +08:00
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();
}
2025-04-08 14:07:20 +08:00
protected override void SetGuideState()
{
2025-04-08 19:05:57 +08:00
base.SetGuideState();
2025-04-08 14:07:20 +08:00
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;
2025-04-08 19:05:57 +08:00
base.RecoverState();
2025-04-08 14:07:20 +08:00
}
2025-04-09 16:00:50 +08:00
/// <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);
}
}
2025-04-08 14:07:20 +08:00
}
2024-05-27 13:32:18 +08:00
/// <summary>
2025-04-08 16:03:25 +08:00
/// 点击敌人
2024-05-27 13:32:18 +08:00
/// </summary>
2025-04-08 16:03:25 +08:00
internal sealed class ClickEnemyGuide : GuideStepBase
2024-05-27 15:39:03 +08:00
{
2025-04-08 16:03:25 +08:00
public static ClickEnemyGuide Create(DataGuideCfg cfg)
{
return new ClickEnemyGuide(cfg);
}
2024-10-12 12:53:47 +08:00
2024-05-29 16:36:30 +08:00
/// <summary>
2025-04-08 16:03:25 +08:00
/// 地板索引
2024-05-29 16:36:30 +08:00
/// </summary>
2025-04-08 16:03:25 +08:00
private readonly int floorIndex;
2024-05-29 16:36:30 +08:00
2025-04-08 16:03:25 +08:00
private ClickEnemyGuide(DataGuideCfg cfg) : base(cfg)
2024-05-29 16:36:30 +08:00
{
2025-04-08 16:03:25 +08:00
if (Cfg.GuideParams.Length <= 0)
throw new Exception($"引导id{Cfg.Id}, 引导类型:{Cfg.GuideType}参数数量错误1.敌人id");
2024-05-27 13:32:18 +08:00
2025-04-08 16:03:25 +08:00
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;
}
2024-05-29 16:36:30 +08:00
}
2024-05-27 13:32:18 +08:00
2024-05-29 16:36:30 +08:00
protected override async void DoGuide()
{
2024-10-10 13:59:48 +08:00
try
{
base.DoGuide();
2024-07-02 14:23:13 +08:00
2025-04-08 16:03:25 +08:00
await UI_GuideController.OpenByClickFloor(floorIndex, Cfg);
2024-10-10 13:59:48 +08:00
}
catch (Exception e)
{
DebugUtil.LogError($"引导id{Cfg.Id},执行错误,异常信息:{e}");
}
2024-07-02 16:05:37 +08:00
}
protected override void SetGuideState()
{
2025-04-08 19:05:57 +08:00
base.SetGuideState();
2025-04-08 16:03:25 +08:00
UIRoot.Instance.IsEnableGraphicRaycasterByGuide(false);
GuideManager.Instance.IsControlFloor = true;
GuideManager.Instance.FloorIndex = floorIndex;
}
protected override void RecoverState()
{
2025-04-08 16:03:25 +08:00
UIRoot.Instance.IsEnableGraphicRaycasterByGuide(true);
GuideManager.Instance.IsControlFloor = false;
GuideManager.Instance.FloorIndex = -1;
2025-04-08 19:05:57 +08:00
base.RecoverState();
}
2024-07-02 16:05:37 +08:00
}
2024-07-02 19:29:18 +08:00
/// <summary>
2025-04-08 16:03:25 +08:00
/// 指向UI说明
2024-07-02 19:29:18 +08:00
/// </summary>
2025-04-08 16:03:25 +08:00
internal sealed class ArrowUITipGuide : GuideStepBase
2024-07-02 16:05:37 +08:00
{
2025-04-08 16:03:25 +08:00
public static ArrowUITipGuide Create(DataGuideCfg cfg)
{
return new ArrowUITipGuide(cfg);
}
2024-07-02 16:05:37 +08:00
/// <summary>
/// UI名
/// </summary>
private readonly string uiName;
/// <summary>
/// 按钮路径
/// </summary>
private readonly string buttonPath;
2024-10-12 12:53:47 +08:00
2025-04-08 16:03:25 +08:00
public ArrowUITipGuide(DataGuideCfg cfg) : base(cfg)
2024-07-02 16:05:37 +08:00
{
2025-04-08 16:03:25 +08:00
if (Cfg.GuideParams.Length > 1)
2024-10-10 13:59:48 +08:00
{
2025-04-08 16:03:25 +08:00
uiName = cfg.GuideParams[0];
buttonPath = cfg.GuideParams[1];
2024-10-10 13:59:48 +08:00
}
2024-07-02 16:05:37 +08:00
}
protected override async void DoGuide()
{
2024-10-10 13:59:48 +08:00
try
{
base.DoGuide();
2024-07-02 16:05:37 +08:00
2025-04-08 16:03:25 +08:00
await UI_GuideController.OpenByArrowUITip(uiName, buttonPath, Cfg);
2024-10-10 13:59:48 +08:00
}
catch (Exception e)
{
DebugUtil.LogError($"引导id{Cfg.Id},执行错误,异常信息:{e}");
}
2024-05-29 16:36:30 +08:00
}
2024-05-27 15:39:03 +08:00
}
2024-05-27 13:32:18 +08:00
2024-07-01 13:08:37 +08:00
/// <summary>
2025-04-08 19:05:57 +08:00
/// 点击引导按钮
2024-07-01 13:08:37 +08:00
/// </summary>
2025-04-08 19:05:57 +08:00
internal sealed class ClickButtonGuide : GuideStepBase
2024-07-01 13:08:37 +08:00
{
2025-04-08 19:05:57 +08:00
public static ClickButtonGuide Create(DataGuideCfg cfg)
{
return new ClickButtonGuide(cfg);
}
2024-07-01 13:08:37 +08:00
/// <summary>
2025-04-08 16:03:25 +08:00
/// UI名
2024-07-01 13:08:37 +08:00
/// </summary>
2025-04-08 16:03:25 +08:00
private readonly string uiName;
/// <summary>
/// 按钮路径
/// </summary>
private readonly string buttonPath;
2024-07-01 13:08:37 +08:00
2025-04-08 19:05:57 +08:00
public ClickButtonGuide(DataGuideCfg cfg) : base(cfg)
2024-07-01 13:08:37 +08:00
{
2025-04-08 19:05:57 +08:00
if (Cfg.GuideParams.Length < 2)
throw new Exception($"引导id{Cfg.Id}, 引导类型:{Cfg.GuideType}参数数量错误1.UI名2.按钮路径");
2024-07-01 13:08:37 +08:00
2025-04-08 19:05:57 +08:00
uiName = Cfg.GuideParams[0];
buttonPath = Cfg.GuideParams[1];
2024-07-01 13:08:37 +08:00
}
protected override async void DoGuide()
{
2024-10-10 13:59:48 +08:00
try
{
base.DoGuide();
2025-04-08 19:05:57 +08:00
await UI_GuideController.OpenByButton(uiName, buttonPath, Cfg);
2024-10-10 13:59:48 +08:00
}
catch (Exception e)
{
DebugUtil.LogError($"引导id{Cfg.Id},执行错误,异常信息:{e}");
}
}
2025-04-08 19:05:57 +08:00
}
/// <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}");
}
}
}
2025-04-08 19:05:57 +08:00
/*
#region 引导点击
2024-07-03 14:56:11 +08:00
2024-10-10 16:05:12 +08:00
/// <summary>
2025-04-08 16:03:25 +08:00
/// 滑动按钮
2024-10-10 16:05:12 +08:00
/// </summary>
2025-04-08 16:03:25 +08:00
internal sealed class SliderButtonStep : GuideStepBase
2024-10-10 16:05:12 +08:00
{
/// <summary>
/// UI名
/// </summary>
private readonly string uiName;
2024-10-12 12:53:47 +08:00
2024-10-10 16:05:12 +08:00
/// <summary>
/// 按钮路径
/// </summary>
private readonly string buttonPath;
2025-04-08 16:03:25 +08:00
/// <summary>
/// 地板索引
/// </summary>
private readonly int floorIndex;
public SliderButtonStep(DataGuideCfg cfg) : base(cfg)
2024-10-10 16:05:12 +08:00
{
2025-04-08 16:03:25 +08:00
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)
2024-10-10 16:05:12 +08:00
{
2025-04-08 16:03:25 +08:00
if (int.TryParse(Cfg.GuideTypeParams[2], out int index))
floorIndex = index;
else
throw new Exception($"引导id{Cfg.Id}, 引导类型:{Cfg.GuideStepType}第3个参数类型错误应该为int类型");
2024-10-10 16:05:12 +08:00
}
}
protected override async void DoGuide()
{
try
{
base.DoGuide();
2025-04-08 16:03:25 +08:00
await UI_GuideController.Open(UI_GuideController.E_GuideArrowType.SliderButton, uiName, buttonPath, Cfg,
floorIndex);
2024-10-10 16:05:12 +08:00
}
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);
2024-10-10 16:05:12 +08:00
}
protected override void RecoverState()
{
if (LevelManager.Instance.IsInLevel &&
null != LevelManager.Instance.CurrentLevel &&
LevelManager.Instance.CurrentLevel.IsInBattle())
LevelManager.Instance.CurrentLevel.SetSpeed(ELevelSpeed.DEFAULT_SPEED);
2024-10-10 16:05:12 +08:00
}
}
2024-10-12 12:53:47 +08:00
2025-04-08 16:03:25 +08:00
2024-10-16 13:02:48 +08:00
/// <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);
2024-10-16 13:39:24 +08:00
GuideManager.Instance.IsControlFloor = true;
GuideManager.Instance.FloorIndex = floorIndex;
EventManager.Instance.Register(EventManager.EventName.Guide_CancelModeFight, OnCancelFightModel);
2024-10-16 13:02:48 +08:00
}
protected override void RecoverState()
{
2024-10-16 13:39:24 +08:00
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);
2024-10-16 13:39:24 +08:00
GuideManager.Instance.IsControlFloor = false;
GuideManager.Instance.FloorIndex = -1;
}
private async void OnCancelFightModel()
{
await UniTask.Delay(300);
2024-10-16 13:39:24 +08:00
await UI_GuideController.Open(UI_GuideController.E_GuideArrowType.SliderButton, uiName, buttonPath, Cfg, floorIndex);
2024-10-16 13:02:48 +08:00
}
}
2024-10-28 14:22:54 +08:00
/// <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
2024-07-01 13:08:37 +08:00
2024-05-29 13:04:51 +08:00
/// <summary>
2024-10-15 18:17:40 +08:00
/// 显示引导提示
2024-05-29 13:04:51 +08:00
/// </summary>
2024-10-15 18:17:40 +08:00
internal sealed class ShowGuideTipStep : GuideStepBase
2024-05-29 13:04:51 +08:00
{
2024-10-15 18:17:40 +08:00
/// <summary>
/// 引导提示配置id
/// </summary>
private readonly int guideTipCfgId;
public ShowGuideTipStep(DataGuideCfg cfg) : base(cfg)
2024-05-29 16:36:30 +08:00
{
2024-10-15 18:17:40 +08:00
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类型");
2024-05-29 16:36:30 +08:00
}
2024-05-29 13:04:51 +08:00
2024-10-15 18:17:40 +08:00
protected override async void DoGuide()
2024-05-29 16:36:30 +08:00
{
2024-10-10 13:59:48 +08:00
try
{
base.DoGuide();
2024-10-15 18:17:40 +08:00
await UI_GuideTipController.Open(guideTipCfgId);
2024-10-10 13:59:48 +08:00
}
catch (Exception e)
{
DebugUtil.LogError($"引导id{Cfg.Id},执行错误,异常信息:{e}");
}
2024-05-29 16:36:30 +08:00
}
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);
}
2024-05-29 13:04:51 +08:00
}
2024-05-22 19:08:14 +08:00
2024-05-28 13:40:44 +08:00
/// <summary>
2024-05-29 16:36:30 +08:00
/// 关卡上阵
2024-05-28 13:40:44 +08:00
/// </summary>
2024-05-29 16:36:30 +08:00
internal sealed class LevelEmbattleStep : GuideStepBase
2024-05-28 13:40:44 +08:00
{
2024-05-29 16:36:30 +08:00
public LevelEmbattleStep(DataGuideCfg cfg) : base(cfg)
{
}
2024-05-28 13:40:44 +08:00
2024-06-04 18:27:32 +08:00
protected override async UniTask DoBeforeGuide()
2024-05-29 16:36:30 +08:00
{
2024-06-04 18:27:32 +08:00
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()
{
2024-10-10 13:59:48 +08:00
try
{
base.DoGuide();
2024-10-10 13:59:48 +08:00
await UI_GuideController.Open(Cfg, false);
}
catch (Exception e)
{
DebugUtil.LogError($"引导id{Cfg.Id},执行错误,异常信息:{e}");
}
2024-05-30 16:49:27 +08:00
}
protected override void SetGuideState()
{
}
protected override void RecoverState()
{
}
2024-05-30 16:49:27 +08:00
}
2024-05-31 14:06:02 +08:00
2024-10-16 17:40:49 +08:00
#region 编队相关
2024-10-15 20:05:34 +08:00
2024-10-16 17:40:49 +08:00
/// <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()
{
}
}
2024-10-15 20:05:34 +08:00
2024-10-16 17:40:49 +08:00
#endregion
2025-04-07 14:51:11 +08:00
*/
2024-05-22 19:08:14 +08:00
}