浏览代码

Adding Random time elapsed condition

/main
Amel Negra 4 年前
当前提交
eafd1d40
共有 2 个文件被更改,包括 36 次插入0 次删除
  1. 25
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/TimeElapsedRandomConditionSO.cs
  2. 11
      UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/TimeElapsedRandomConditionSO.cs.meta

25
UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/TimeElapsedRandomConditionSO.cs


using UnityEngine;
using UOP1.StateMachine;
using UOP1.StateMachine.ScriptableObjects;
[CreateAssetMenu(menuName = "State Machines/Conditions/Time elapsed random")]
public class TimeElapsedRandomConditionSO : StateConditionSO<TimeElapsedRandomCondition>
{
public float minTimerLength = .5f;
public float maxTimerLength = .5f;
}
public class TimeElapsedRandomCondition : Condition
{
private float _startTime;
private float timerLength = .5f;
private TimeElapsedRandomConditionSO _originSO => (TimeElapsedRandomConditionSO)base.OriginSO; // The SO this Condition spawned from
public override void OnStateEnter()
{
_startTime = Time.time;
timerLength = Random.Range(_originSO.minTimerLength, _originSO.maxTimerLength);
}
protected override bool Statement() => Time.time >= _startTime + timerLength;
}

11
UOP1_Project/Assets/Scripts/Characters/StateMachine/Conditions/TimeElapsedRandomConditionSO.cs.meta


fileFormatVersion: 2
guid: 176cefe776b9f114393e9f982ce6e208
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存