32 lines
840 B
C#
32 lines
840 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
public class AiSequence : AiComposite {
|
|
|
|
private int _currentId = 0;
|
|
|
|
protected override void OnBegin(AiBlackboard blackboard) {
|
|
_currentId = 0;
|
|
}
|
|
|
|
protected override BehaviorStatus OnExecute(AiBlackboard blackboard) {
|
|
if (children == null || children.Length == 0) {
|
|
Debug.LogError("Broken behavior! No children!");
|
|
return BehaviorStatus.Invalid;
|
|
}
|
|
|
|
//Debug.Log("Sequence: " + behaviorName);
|
|
|
|
while(_currentId < children.Length) {
|
|
var current = children[_currentId];
|
|
var result = current.Tick(blackboard);
|
|
if (result != BehaviorStatus.Success) {
|
|
return result;
|
|
}
|
|
_currentId++;
|
|
}
|
|
|
|
return BehaviorStatus.Success;
|
|
}
|
|
}
|