您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
28 行
719 B
28 行
719 B
using UnityEngine;
|
|
using UOP1.StateMachine;
|
|
using UOP1.StateMachine.ScriptableObjects;
|
|
|
|
[CreateAssetMenu(fileName = "TimeElapsed", menuName = "State Machines/Conditions/Time elapsed")]
|
|
public class TimeElapsedConditionSO : StateConditionSO
|
|
{
|
|
[SerializeField] float _timerLength = .5f;
|
|
protected override Condition CreateCondition() => new TimeElapsedCondition(_timerLength);
|
|
}
|
|
|
|
public class TimeElapsedCondition : Condition
|
|
{
|
|
private float _timerLength;
|
|
private float _startTime;
|
|
|
|
public override void OnStateEnter()
|
|
{
|
|
_startTime = Time.time;
|
|
}
|
|
|
|
public TimeElapsedCondition(float timerLength)
|
|
{
|
|
_timerLength = timerLength;
|
|
}
|
|
|
|
public override bool Statement() => Time.time >= _startTime + _timerLength;
|
|
}
|