您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
44 行
1.3 KiB
44 行
1.3 KiB
using UnityEngine;
|
|
using UOP1.StateMachine;
|
|
using UOP1.StateMachine.ScriptableObjects;
|
|
|
|
/// <summary>
|
|
/// An Action to clear a <see cref="Protagonist.movementVector"/> at the <see cref="StateAction.SpecificMoment"/> <see cref="StopMovementActionSO.Moment"/>
|
|
/// </summary>
|
|
[CreateAssetMenu(fileName = "StopMovementAction", menuName = "State Machines/Actions/Stop Movement")]
|
|
public class StopMovementActionSO : StateActionSO
|
|
{
|
|
[SerializeField] private StateAction.SpecificMoment _moment = default;
|
|
public StateAction.SpecificMoment Moment => _moment;
|
|
|
|
protected override StateAction CreateAction() => new StopMovement();
|
|
}
|
|
|
|
public class StopMovement : StateAction
|
|
{
|
|
private Protagonist _protagonist;
|
|
private new StopMovementActionSO OriginSO => (StopMovementActionSO)base.OriginSO;
|
|
|
|
public override void Awake(StateMachine stateMachine)
|
|
{
|
|
_protagonist = stateMachine.GetComponent<Protagonist>();
|
|
}
|
|
|
|
public override void OnUpdate()
|
|
{
|
|
if (OriginSO.Moment == SpecificMoment.OnUpdate)
|
|
_protagonist.movementVector = Vector3.zero;
|
|
}
|
|
|
|
public override void OnStateEnter()
|
|
{
|
|
if (OriginSO.Moment == SpecificMoment.OnStateEnter)
|
|
_protagonist.movementVector = Vector3.zero;
|
|
}
|
|
|
|
public override void OnStateExit()
|
|
{
|
|
if (OriginSO.Moment == SpecificMoment.OnStateExit)
|
|
_protagonist.movementVector = Vector3.zero;
|
|
}
|
|
}
|