NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/PlayerSkill/State/PlayerSkillStateIdle.cs

78 lines
2.5 KiB
C#
Raw Normal View History

2023-12-06 17:05:07 +08:00
using Framework;
using Gameplay.Common;
2023-12-19 15:01:19 +08:00
using Gameplay.PlayerSkill.Data;
2023-12-06 17:05:07 +08:00
using LTGame;
using UnityEngine;
2023-12-06 14:08:57 +08:00
namespace Gameplay.PlayerSkill.State
2023-12-06 12:22:59 +08:00
{
public class PlayerSkillStateIdle : BasePlayerSkillState
{
2023-12-06 15:32:45 +08:00
public PlayerSkillStateIdle(PlayerSkillManager owner) : base(owner, EPlayerSkillState.Idle)
2023-12-06 12:22:59 +08:00
{
}
2023-12-06 14:08:57 +08:00
2023-12-06 17:05:07 +08:00
protected override void _OnEnter(NBaseState exitState,
object param)
{
base._OnEnter(exitState, param);
EventManager.Instance.Register<EDReadyPlayerSkill>(EventManager.EventName.INFIGHT_PLAYER_SKILL_READYUSE, _OnRecvReadySkill);
}
2023-12-06 14:08:57 +08:00
protected override void _OnRunning()
{
base._OnRunning();
2023-12-06 15:32:45 +08:00
_FakeInput();
2023-12-06 17:05:07 +08:00
}
protected override void _OnExit(NBaseState exitState,
object param)
{
base._OnExit(exitState, param);
EventManager.Instance.Unregister<EDReadyPlayerSkill>(EventManager.EventName.INFIGHT_PLAYER_SKILL_READYUSE, _OnRecvReadySkill);
2023-12-06 15:32:45 +08:00
}
private void _FakeInput()
{
2023-12-06 14:08:57 +08:00
// TODO: 临时逻辑, 用于测试
if (Input.GetKeyDown(KeyCode.Q))
{
2023-12-06 17:05:07 +08:00
var readyData = new EDReadyPlayerSkill();
readyData.playerSkillId = 91101;
2023-12-06 17:05:07 +08:00
EventManager.Instance.Send(EventManager.EventName.INFIGHT_PLAYER_SKILL_READYUSE, readyData);
2023-12-06 14:08:57 +08:00
}
}
2023-12-06 17:05:07 +08:00
private void _OnRecvReadySkill(EDReadyPlayerSkill readyData)
{
2023-12-06 18:36:15 +08:00
if (owner.isInCD) return;
2023-12-06 17:05:07 +08:00
owner.ReadySkill(readyData.playerSkillId);
2024-07-05 16:14:23 +08:00
2023-12-06 17:05:07 +08:00
isFinished = true;
2023-12-11 16:25:13 +08:00
switch (owner.readySkillConfig.PreSelectType)
{
2023-12-19 15:01:19 +08:00
case EPreSelectType.ChoosePos:
2023-12-11 16:25:13 +08:00
nextState = EPlayerSkillState.ChoosePos;
break;
2023-12-19 15:01:19 +08:00
case EPreSelectType.AllSelfUnitHasEffect:
2023-12-11 16:25:13 +08:00
nextState = EPlayerSkillState.ShowGlobalEffect;
break;
2023-12-19 15:01:19 +08:00
case EPreSelectType.NoEffect:
nextState = EPlayerSkillState.PreNoEffect;
break;
2023-12-11 16:25:13 +08:00
default:
nextState = EPlayerSkillState.Idle;
DebugUtil.LogError("暂未实现的技能选择类型: " + owner.readySkillConfig.PreSelectType);
break;
}
2024-07-05 16:14:23 +08:00
EventManager.Instance.Send(EventManager.EventName.Guide_UseSkill);
2023-12-06 17:05:07 +08:00
}
2023-12-06 12:22:59 +08:00
}
}