Esempio n. 1
0
        public void BindBehaviourTree(YuAIBehaviorBase rootTreeBehaviour, BehaviorTreeBaseNode BehaviourNode)
        {
            var currentBehaviour  = rootTreeBehaviour;
            var childrenBehaviour = currentBehaviour.GetChildren();

            if (childrenBehaviour != null)
            {
                foreach (var child in childrenBehaviour)
                {
                    var childNode = new BehaviorTreeBaseNode();
                    BindBehaviourTree(child, childNode);
                    childNode.BindBehaviour(child);
                    BehaviourNode.childNodes.Add(childNode);
                }
            }
        }
Esempio n. 2
0
        public void AddChildBehaviourNode(NodeType nodeType, object parme)
        {
            BehaviorTreeBaseNode behaviorNode = new BehaviorTreeBaseNode();

            switch (nodeType)
            {
            case NodeType.YuAIRepeat:
                int times = (int)parme;
                YuAIBehaviorBase behavior = new YuAIRepeat(times);
                behaviorNode.BindBehaviour(behavior);
                currentBehaviourNode.BindingBehaviour?.AddChild(behavior);
                break;

            case NodeType.Simple:
                var action = new UnitPatrolMoveAction();
                action.Init(parme);
                currentBehaviourNode?.BindingBehaviour?.AddChild(action);
                behaviorNode.BindBehaviour(action);
                break;
            }

            currentBehaviourNode.childNodes.Add(behaviorNode);
        }