*
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class AiRoot : AiBehavior {
|
||||
public AiBehavior child;
|
||||
public AiBlackboard blackboard;
|
||||
private Health _health;
|
||||
|
||||
void Start() {
|
||||
blackboard.SetValue("gameobject", gameObject);
|
||||
_health = GetComponent<Health>();
|
||||
}
|
||||
|
||||
void FixedUpdate() {
|
||||
OnExecute(blackboard);
|
||||
}
|
||||
|
||||
protected override BehaviorStatus OnExecute(AiBlackboard blackboard) {
|
||||
if (enabled && (_health == null || !_health.Dead)) {
|
||||
if (child == null) {
|
||||
Debug.LogWarning("AiRoot: child is null");
|
||||
return BehaviorStatus.Invalid;
|
||||
}
|
||||
return child.Tick(blackboard);
|
||||
}
|
||||
return BehaviorStatus.Success;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user