示例#1
0
        private void DisplayParentNode(BehaviourTree tree, IBehaviourTreeNodeParent node, int level)
        {
            var style = new GUIStyle(GUI.skin.label)
            {
                richText  = true,
                padding   = new RectOffset(10 * level, 0, 0, 0),
                fontStyle = tree.GetRunningNode().Equals(node) ? FontStyle.Bold : FontStyle.Normal
            };

            GUILayout.Label($"<color=#{GetColorByStatus(node.LastStatus)}>{node.GetType().Name}</color>", style);

            foreach (var child in node.Children)
            {
                if (child is IBehaviourTreeNodeParent subParent)
                {
                    DisplayParentNode(tree, subParent, level + 1);
                    continue;
                }

                style.padding   = new RectOffset(10 * (level + 1), 0, 0, 0);
                style.fontStyle = tree.GetRunningNode().Equals(child) ? FontStyle.Bold : FontStyle.Normal;

                GUILayout.Label($"<color=#{GetColorByStatus(child.LastStatus)}>{child.GetType().Name}</color>", style);
            }
        }
示例#2
0
        public BehaviourTreeBuilder AddParent(IBehaviourTreeNodeParent parent)
        {
            if (this.parentStack.Count > 0)
            {
                this.parentStack.Peek().AddChild(parent);
            }

            this.parentStack.Push(parent);

            return(this);
        }
示例#3
0
        public BehaviourTreeBuilder End()
        {
            this.top = this.parentStack.Pop();

            return(this);
        }
示例#4
0
 public BehaviourTree(IBehaviourTreeNodeParent root)
 {
     Root = root;
 }