Exemplo n.º 1
0
        public static BTNodeData CreateNodeData(JSON js)
        {
            string baseTypeStr = js.ToString("baseType");
            TYPE   baseType    = (TYPE)Enum.Parse(typeof(TYPE), baseTypeStr);

            if (baseType == TYPE.ACTION)
            {
                return(BTActionNodeData.CreateActionNodeData(js));
            }
            else if (baseType == TYPE.DECORATOR)
            {
                return(BTDecoratorNodeData.CreateDecoratorNodeData(js));
            }
            else if (baseType == TYPE.COMPOSITE)
            {
                return(BTCompositeNodeData.CreateCompositeNodeData(js));
            }
            else if (baseType == TYPE.ROOT)
            {
                BTNodeData rootNodeData = BTDecoratorNodeData.CreateRootNodeData(js);
                rootNodeData.type = TYPE.ROOT;
                return(rootNodeData);
            }
            else
            {
                UnityEngine.Debug.Log("Error: Invalid Node Type: " + baseTypeStr);
            }
            return(null);
        }
Exemplo n.º 2
0
        public BTCompositeNode(BTCompositeNodeData btCompositeNodeData, BTree bTree, BTNode parent) : base(bTree, parent)
        {
            List <BTNodeData> childrenData = btCompositeNodeData.Children;

            _children = new BTNode[childrenData.Count];
            for (int i = 0; i < childrenData.Count; ++i)
            {
                _children[i] = BTNode.CreateNode(childrenData[i], bTree, this);
            }
        }