public override NodeStatus Tick(BehaviorBlackboard data) { List <NodeOutput> nodes = this.Outputs; BaseBehaviorNode[] nodeArray = new BaseBehaviorNode[3]; int count = 0; foreach (NodeOutput node in nodes) { if (node.connections.Count == 0) { continue; } nodeArray[count] = (BaseBehaviorNode)(node.connections[0].body); count++; } if (count == 0) { Debug.LogError("Behavor Tree Designer\nNo output node is connected on node: " + this.name); return(NodeStatus.ERROR); } int rand = UnityEngine.Random.Range(0, count); NodeStatus childstatus = nodeArray[rand].Tick(data); return(childstatus); }
public override NodeStatus Tick(BehaviorBlackboard data) { if (this.Outputs[0].connections.Count == 0) { Debug.LogError("Behavor Tree Designer\nOutput node is not connected on node: " + this.name); return(NodeStatus.ERROR); } BaseBehaviorNode node = (BaseBehaviorNode)this.Outputs[0].connections[0].body; if (start) { data.Add(guid.ToString(), Time.time); } float time = (float)data.Get(guid.ToString()); if (time + waitTime > Time.time) { start = false; return(NodeStatus.RUNNING); } else { start = true; return(node.Tick(data)); } }
public override NodeStatus Tick(BehaviorBlackboard data) { if (this.Outputs[0].connections.Count == 0) { Debug.LogError("Behavor Tree Designer\nOutput node is not connected on node: " + this.name); return(NodeStatus.ERROR); } BaseBehaviorNode node = (BaseBehaviorNode)this.Outputs[0].connections[0].body; NodeStatus status = NodeStatus.SUCCESS; int rep = (int)data.Get(guid.ToString()); status = node.Tick(data); if (status == NodeStatus.RUNNING) { return(status); } rep += 1; if (rep < repNumber) { status = NodeStatus.RUNNING; data.Add(guid.ToString(), rep); } else { data.Add(guid.ToString(), 0); } return(status); }
public override void Init(BehaviorBlackboard data) { base.Init(data); if (subTree == null) { Debug.LogError("Behavor Tree Designer\nNo subtree assigned!"); return; } subRoot = subTree.GetRootNode(); subRoot.Init(data); }
public override NodeStatus Tick(BehaviorBlackboard data) { if (this.Outputs[0].connections.Count == 0) { Debug.LogError("Behavor Tree Designer\nRoot node is not connected."); return(NodeStatus.ERROR); } BaseBehaviorNode node = (BaseBehaviorNode)this.Outputs[0].connections[0].body; return(node.Tick(data)); }
public override NodeStatus Tick(BehaviorBlackboard data) { if (this.Outputs[0].connections.Count == 0) { Debug.LogError("Behavor Tree Designer\nOutput node is not connected on node: " + this.name); return(NodeStatus.ERROR); } BaseBehaviorNode node = (BaseBehaviorNode)this.Outputs[0].connections[0].body; NodeStatus status = node.Tick(data); Debug.Log("Behavor Tree Designer Logger\nComing from: " + node.name + ". Result: " + status.ToString()); return(status); }
private void Awake() { if (behaviorTree == null) { Debug.LogError("Behavor Tree Designer\nNo behavior assigned!"); return; } if (agent == null) { Debug.LogError("Behavor Tree Designer\nNo agent assigned!"); return; } data = new BehaviorBlackboard(); data.Add("_BTD_Agent", agent); rootNode = behaviorTree.GetRootNode(); }
private void Start() { if (behaviorTree == null) { Debug.LogError("Behavor Tree Designer\nNo behavior assigned!"); return; } if (agent == null) { Debug.LogError("Behavor Tree Designer\nNo agent assigned!"); return; } data = new BehaviorBlackboard(); data.Add("Agent", agent); rootNode = behaviorTree.GetRootNode(); rootNode.Init(data); InvokeRepeating("DoTick", 0, tickTime); }
public override NodeStatus Tick(BehaviorBlackboard data) { if (this.Outputs[0].connections.Count == 0) { Debug.LogError("Behavor Tree Designer\nOutput node is not connected on node: " + this.name); return(NodeStatus.ERROR); } BaseBehaviorNode node = (BaseBehaviorNode)this.Outputs[0].connections[0].body; NodeStatus status = node.Tick(data); if (status == NodeStatus.SUCCESS) { status = NodeStatus.FAILURE; } else if (status == NodeStatus.FAILURE) { status = NodeStatus.SUCCESS; } return(status); }
protected void Init(BaseBehaviorNode node) { node.name = this.GetType().Name; node.Id = node.name; node.tex = (Texture)Resources.Load("BehavorIcons/" + node.Id); }