Exemple #1
0
    void drawNodes()
    {
        for (int i = 0; i < _nodes.Count; i++)
        {
            _nodes[i].draw();

            _nodes[i].drawConnectedChilds();

            if (_nodes[i].parentButtonPressed())
            {
                selectedChildNode = _nodes[i];

                if (selectedParentNode != null)
                {
                    setConnection();
                }
            }

            if (_nodes[i].childButtonPressed())
            {
                selectedParentNode = _nodes[i];

                if (selectedChildNode != null)
                {
                    setConnection();
                }
            }
        }
    }
Exemple #2
0
    void setConnection()
    {
        selectedParentNode.addChild(selectedChildNode);
        selectedChildNode.setParent(selectedParentNode);

        selectedChildNode  = null;
        selectedParentNode = null;

        fillBHTreeComponent(script.GetClass());
    }
    public void setParent(BHEditorNode parent)
    {
        if (parent == this)
        {
            return;
        }

        Debug.Log("seting parent");
        if (parent != _parent && _parent != null)
        {
            _parent.removeChild(this);
        }

        _parent = parent;
    }
Exemple #4
0
    void addNode(NodeType type, Vector2 pos)
    {
        BHEditorNode node = new BHEditorNode(type,
                                             pos,
                                             nodeBoxStyle,
                                             childButtonStyle,
                                             parentButtonStyle);

        node.removeNode = removeNode;

        if (type == NodeType.Action || type == NodeType.Conditional)
        {
            node.setScriptType(script.GetClass());
        }

        _nodes.Add(node);
    }
    public void addChild(BHEditorNode child)
    {
        if (!_childNodes.Contains(child))
        {
            if (child != this)
            {
                _childNodes.Add(child);
                Debug.Log("child added");
            }
        }

        else
        {
            removeChild(child);
            _childNodes.Add(child);
            Debug.Log("child added without repeating");
        }
    }
Exemple #6
0
    int readBHTreeComponent(int index, out BHEditorNode bhEditorNode)
    {
        BHNodeSerializable serializableNode = behaviourTreeComponent.bhNodesSerializable[index];

        bhEditorNode = new BHEditorNode((NodeType)serializableNode.nodeType,
                                        serializableNode.editorPos,
                                        nodeBoxStyle, childButtonStyle, parentButtonStyle);

        bhEditorNode.setFunctionName(serializableNode.functionName);
        bhEditorNode.removeNode = removeNode;
        bhEditorNode.setScriptType(script.GetClass());

        _nodes.Add(bhEditorNode);

        for (int i = 0; i < serializableNode.childCount; i++)
        {
            BHEditorNode childEditorNode;
            index = readBHTreeComponent(++index, out childEditorNode);
            childEditorNode.setParent(bhEditorNode);
            bhEditorNode.addChild(childEditorNode);
        }

        return(index);
    }
 public void clearParent()
 {
     _parent = null;
 }
 public void removeChild(BHEditorNode child)
 {
     _childNodes.Remove(child);
 }
Exemple #9
0
 void removeNode(BHEditorNode node)
 {
     _nodes.Remove(node);
     fillBHTreeComponent(script.GetClass());
 }