private void InitChildNodes()
        {
            if (rootNodes.Count != 0)
            {
                return;
            }

            for (int i = 0; i < transform.childCount; i++)
            {
                BehaviourNode temp = transform.GetChild(i).GetComponent <BehaviourNode>();
                if (temp)
                {
                    rootNodes.Add(temp);
                }
            }
        }
Beispiel #2
0
        public override void ResetNode(int _depth, int _nodeNumber, BehaviourNode _parentNode, ThroughEnum _through = ThroughEnum.Depth)
        {
            base.ResetNode(_depth, _nodeNumber, _parentNode);

            if (_through == ThroughEnum.Depth)
            {
                int nodeNumberToChildNode = -1;
                for (int i = 0; i < nodes.Count; i++)
                {
                    var childNode = nodes[i];
                    nodeNumberToChildNode = nodeNumberToChildNode == -1 ? _nodeNumber + (i + 1) : nodes[i - 1].GetTreeLastLeafNumber() + 1;
                    childNode.ResetNode(_depth + 1, nodeNumberToChildNode, this, _through);
                }
            }
            else if (_through == ThroughEnum.Breadth)
            {
                if (_parentNode == null)
                {
                    Queue <NodeReseterData> behaviourQueue = new Queue <NodeReseterData>();
                    behaviourQueue.Enqueue(new NodeReseterData {
                        depth = _depth, parentNode = null, reseterNode = this
                    });

                    while (behaviourQueue.Count != 0)
                    {
                        var cache = behaviourQueue.Dequeue();
                        cache.reseterNode.ResetNode(cache.depth, _nodeNumber++, cache.parentNode);

                        if (cache.reseterNode.GetType().BaseType == typeof(CompositesNode))
                        {
                            foreach (var v in ((CompositesNode)cache.reseterNode).Nodes)
                            {
                                behaviourQueue.Enqueue(new NodeReseterData
                                {
                                    reseterNode = v, depth = cache.depth + 1, parentNode = cache.reseterNode
                                });
                            }
                        }
                    }
                }
            }
        }
Beispiel #3
0
 public override void ResetNode(int _depth, int _nodeNumber, BehaviourNode _parentNode, ThroughEnum _through = ThroughEnum.Depth)
 {
     currentNodeNumber = 0;
     base.ResetNode(_depth, _nodeNumber, _parentNode, _through);
 }