29 lines
753 B
C#
29 lines
753 B
C#
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;
|
|
}
|
|
}
|