Exemple #1
0
        public void Load(JSON js, string filePath)
        {
            ClearAll();

            SetFilePath(filePath);
            _name = js.ToString("name");

            JSON[] nodeListJS = js.ToArray <JSON>("bTree");
            for (int i = 0; i < nodeListJS.Length; ++i)
            {
                float           posX     = nodeListJS[i].ToFloat("posX");
                float           posY     = nodeListJS[i].ToFloat("posY");
                ZNode.BASE_TYPE baseType = ZEditorUtils.ParseEnum <ZNode.BASE_TYPE>(nodeListJS[i].ToString("baseType"));
                ZNode           newNode  = null;
                if (baseType == ZNode.BASE_TYPE.ROOT)
                {
                    newNode = CreateRoot(posX, posY);
                }
                else if (baseType == ZNode.BASE_TYPE.SUBTREE)
                {
                    newNode = CreateBaseNode(baseType, posX, posY, nodeListJS[i]);
                }
                else if (baseType == ZNode.BASE_TYPE.COMPOSITE)
                {
                    ZNodeComposite.NODE_TYPE nodeType = ZEditorUtils.ParseEnum <ZNodeComposite.NODE_TYPE>(nodeListJS[i].ToString("nodeType"));
                    newNode = CreateCompositeNode(nodeType, posX, posY, nodeListJS[i]);
                }
                else if (baseType == ZNode.BASE_TYPE.DECORATOR)
                {
                    ZNodeDecorator.NODE_TYPE nodeType = ZEditorUtils.ParseEnum <ZNodeDecorator.NODE_TYPE>(nodeListJS[i].ToString("nodeType"));
                    newNode = CreateDecoratorNode(nodeType, posX, posY, nodeListJS[i]);
                }
                else if (baseType == ZNode.BASE_TYPE.ACTION)
                {
                    ZBTActionManager.NODE_TYPE nodeType = ZEditorUtils.ParseEnum <ZBTActionManager.NODE_TYPE>(nodeListJS[i].ToString("nodeType"));
                    newNode = CreateActionNode(nodeType, posX, posY, nodeListJS[i]);
                }
                newNode.Name = nodeListJS[i].ToString("id");
            }

            JSON[] connectionListJS = js.ToArray <JSON>("connections");
            for (int i = 0; i < connectionListJS.Length; ++i)
            {
                int            inId         = connectionListJS[i].ToInt("inNodeId");
                int            outId        = connectionListJS[i].ToInt("outNodeId");
                ZNodeConnector inConnector  = GetNode(inId).OutConnector;
                ZNodeConnector outConnector = GetNode(outId).InConnector;
                if (inConnector != null && outConnector != null)
                {
                    CreateConnection(inConnector, outConnector);
                }
                else
                {
                    Debug.Log("Unable to find in or out connector for node: " + inId.ToString() + " " + outId.ToString());
                }
            }
        }
Exemple #2
0
        public ZNode CreateCompositeNode(ZNodeComposite.NODE_TYPE nodeType, float posX, float posY, JSON js)
        {
            Rect  nodeRect = new Rect(posX, posY, _nodeEditor.SkinItem.nodeWidth, _nodeEditor.SkinItem.nodeHeight);
            ZNode node     = ZNodeComposite.CreateNode(nodeType, this, nodeRect, js);

            if (node != null)
            {
                _nodes.Add(node);
            }
            return(node);
        }
Exemple #3
0
 public Texture GetCompositeNodeImage(ZNodeComposite.NODE_TYPE compositeType)
 {
     for (int i = 0; i < compositeNodes.Length; ++i)
     {
         if (compositeNodes[i].type == compositeType)
         {
             return(compositeNodes[i].icon);
         }
     }
     return(null);
 }
Exemple #4
0
 public void CreateCompositeNode(ZNodeComposite.NODE_TYPE nodeType)
 {
     _currentNodeTree.CreateCompositeNode(nodeType, _nodeScrollView.x + (position.width - SkinItem.leftPanelWidth) / 2, _nodeScrollView.y + (position.height - SkinItem.tabHeight) / 2, null);
 }