コード例 #1
0
    public void Init(SDEContainer container, string text, float width, float height)
    {
        base.Init(SDEComponentType.Label, null,
                  new Rect(0, 0, width, height),
                  SDEStyles.labelDefault, null, null,
                  container);

        Init(text);
    }
コード例 #2
0
    public void Init(SDEContainer container, string text, float width)
    {
        Init(SDEComponentType.TextArea, null,
             new Rect(0, 0, width - 2 * TextAreaManager.X_PAD, 0),
             SDEStyles.textBoxDefault,
             SDEStyles.textBoxDefault,
             SDEStyles.textBoxSelected,
             container);

        Init(text);
    }
コード例 #3
0
    private void ToggleDecision(bool record = true)
    {
        if (record)
        {
            HistoryManager.RecordNode(this);
        }

        nodeType = NodeType.Decision;
        title    = "DECISION";

        rect.width       = NodeManager.TEXT_NODE_WIDTH;
        rect.height      = NodeManager.TEXT_NODE_HEIGHT;
        clickRect.width  = NodeManager.TEXT_NODE_WIDTH;
        clickRect.height = NodeManager.TEXT_NODE_HEIGHT;

        // create a child DecisionBox
        this.childContainer = ScriptableObject.CreateInstance <DecisionBox>();
        ((DecisionBox)this.childContainer).Init(this, "");
    }
コード例 #4
0
    /*
     * DrawDialog() is used when the Node Type is Dialog, and draws a dialog entry menu.
     */
    private void DrawDialog()
    {
        childContainer.Draw();

        // calculate the y position of the dialog buttons
        SDEContainer tempChild = childContainer;
        float        buttonY   = rect.y + rect.height + 2;

        while (true)
        {
            buttonY += tempChild.rect.height;

            if (tempChild.child == null)
            {
                break;
            }

            tempChild = tempChild.child;
        }


        // only draw the remove TextArea button if there are multiple TextAreas
        if (tempChild.parentNode != this)
        {
            if (GUI.Button(new Rect(rect.xMax - 33, buttonY, 16, 16), "-", SDEStyles.textButtonDefault))
            {
                ((DialogBox)tempChild).Remove();
            }
        }

        if (GUI.Button(new Rect(rect.xMax - 16, buttonY, 16, 16), "+", SDEStyles.textButtonDefault))
        {
            HistoryManager.RecordEditor();

            Debug.Log("Adding DialogBox");

            tempChild.child = ScriptableObject.CreateInstance <DialogBox>();
            ((DialogBox)tempChild.child).Init(tempChild, "");
        }
    }
コード例 #5
0
    /*
     * RemoveInterruptNodes() is a helper function for RemoveNode() that removes the associated
     * Interrupt Nodes and appends the Connections of the given Node.
     */
    private static void RemoveInterruptNodes(List <Connection> connectionsToRemove, Node node)
    {
        // get all the associated connections to clear
        SDEContainer      tempContainer = node.childContainer;
        List <Connection> tempConnections;
        List <Node>       nodesToRemove = new List <Node>();
        Node tempNode;

        while (tempContainer != null)
        {
            // get all the connections of the Node's child DialogBoxes
            tempConnections = tempContainer.outPoint.connections;
            connectionsToRemove.AddRange(tempConnections);

            // get all the connected nodes
            for (int i = 0; i < tempConnections.Count; i++)
            {
                tempNode = (Node)tempConnections[i].inPoint.parent;
                if (tempNode.nodeType == NodeType.Interrupt)
                {
                    // queue the Interrupt Node to be removed
                    nodesToRemove.Add(tempNode);

                    // add the default Interrupt Node output connections
                    connectionsToRemove.AddRange(GetConnections(tempNode));
                }
            }

            tempContainer = tempContainer.child;
        }

        // remove the associated interrupt nodes
        for (int i = 0; i < nodesToRemove.Count; i++)
        {
            mainEditor.nodes.Remove(nodesToRemove[i]);
        }
        nodesToRemove = null;
    }
コード例 #6
0
    private static List <Connection> GetConnections(Node node)
    {
        SDEContainer      tempContainer = node.childContainer;
        List <Connection> connections   = new List <Connection>();

        if (node.outPoint != null)
        {
            connections.AddRange(node.outPoint.connections);
        }

        if (node.splitter != null)
        {
            connections.AddRange(node.splitter.positiveOutpoint.connections);
            connections.AddRange(node.splitter.negativeOutpoint.connections);
        }

        while (tempContainer != null)
        {
            connections.AddRange(tempContainer.outPoint.connections);
            tempContainer = tempContainer.child;
        }

        return(connections);
    }
コード例 #7
0
 public virtual void Init(SDEContainer parent)
 {
     this.parent = parent;
 }
コード例 #8
0
 public override void Init(SDEContainer parent, string text)
 {
     base.Init(parent, text);
     Init();
 }
コード例 #9
0
    // goes through everything and assigns CPEIDs to every ConnectionPointEntry and populates container data
    public static List <EditorNodeEntry> PrepassNodeEntries(List <Node> nodes, Dictionary <EditorNodeEntry, Node> nodeMap, Dictionary <ConnectionPoint, int> connectionPointMap)
    {
        List <EditorNodeEntry> entries = new List <EditorNodeEntry>();
        EditorNodeEntry        tempNode;

        for (int i = 0; i < nodes.Count; i++)
        {
            tempNode          = new EditorNodeEntry();
            nodeMap[tempNode] = nodes[i];

            tempNode.inPoint       = new InPointEntry();
            tempNode.inPoint.CPEID = GenerateCPEID();
            connectionPointMap[nodes[i].inPoint] = tempNode.inPoint.CPEID;

            // assign CPEID to outpoints and splitter points based on NodeType
            NodeType type = nodes[i].nodeType;
            if ((type == NodeType.Interrupt ||
                 type == NodeType.SetGlobalFlag ||
                 type == NodeType.SetLocalFlag ||
                 type == NodeType.SetGlobalVariable) &&
                nodes[i].outPoint != null)
            {
                tempNode.outPoint       = new ConnectionPointEntry();
                tempNode.outPoint.CPEID = GenerateCPEID();
                connectionPointMap[nodes[i].outPoint] = tempNode.outPoint.CPEID;
            }

            if ((type == NodeType.CheckGlobalFlag ||
                 type == NodeType.CheckLocalFlag ||
                 type == NodeType.CheckGlobalVariable) &&
                nodes[i].splitter != null)
            {
                tempNode.outPos       = new ConnectionPointEntry();
                tempNode.outNeg       = new ConnectionPointEntry();
                tempNode.outPos.CPEID = GenerateCPEID();
                tempNode.outNeg.CPEID = GenerateCPEID();
                connectionPointMap[nodes[i].splitter.positiveOutpoint] = tempNode.outPos.CPEID;
                connectionPointMap[nodes[i].splitter.negativeOutpoint] = tempNode.outNeg.CPEID;
            }

            // check if it has child elements based on NodeType
            if ((type == NodeType.Interrupt ||
                 type == NodeType.Dialog ||
                 type == NodeType.Decision) &&
                nodes[i].childContainer != null)
            {
                // traverse through the child components and populate the CPEIDs
                SDEContainer      container     = nodes[i].childContainer;
                SDEContainerEntry tempContainer = new SDEContainerEntry();
                tempNode.childContainer = tempContainer;
                while (container != null)
                {
                    tempContainer.outPoint                 = new ConnectionPointEntry();
                    tempContainer.outPoint.CPEID           = GenerateCPEID();
                    connectionPointMap[container.outPoint] = tempContainer.outPoint.CPEID;

                    // get container data
                    switch (container.containerType)
                    {
                    case SDEContainerType.DecisionBox:
                        tempContainer.text = ((DecisionBox)container).textArea.text;
                        break;

                    case SDEContainerType.DialogBox:
                        tempContainer.text = ((DialogBox)container).textArea.text;
                        break;

                    case SDEContainerType.DialogInterrupt:
                        tempContainer.text = ((DialogInterrupt)container).label.text;
                        break;

                    default:
                        throw new UnityException("Malformed SDEContainerType on Save!");
                    }

                    container = container.child;

                    if (container != null)
                    {
                        tempContainer.child = new SDEContainerEntry();
                        tempContainer       = tempContainer.child;
                    }
                }
            }

            entries.Add(tempNode);
        }

        // reset the CPEID counter after assignments are done
        CPEIDCounter = 0;
        return(entries);
    }