예제 #1
0
    public void DrawNodeGraph(Rect graphRect, DialogueAssetBuilder asset)
    {
        if (asset != null)
        {
            m_nodeGraphModel = asset.m_nodeGraphModel;
            m_assetBuilder   = asset;
        }

        if (m_nodeGraphModel.startNodeID == 0)
        {
            int id = m_nodeGraphModel.AddNode(new Vector2(10, 10));
            m_nodeGraphModel.AddOutputPlugToNode(id);
            m_nodeGraphModel.GetDataFromNodeID(id).m_isStartNode = true;
            m_nodeGraphModel.startNodeID = id;
        }

        m_nodeGraphRect = graphRect;
        BeginArea(graphRect);
        Label("Node Graph");

        // write out asset errors

        DrawGrid(graphRect, 20, 0.2f, Color.gray);  // light grid-lines
        DrawGrid(graphRect, 100, 0.4f, Color.gray); // dark grid-lines
        DrawNodes();
        DrawConnections();
        DrawActiveConnection(Event.current);
        if (m_isMultiSelectOn)
        {
            DrawMultiSelectBox();
        }
        EndArea();
    }
예제 #2
0
    public void DrawNodeProperties(Rect propertiesRect, Node selected_node, DialogueAssetBuilder asset)
    {
        if (asset != null)
        {
            m_nodeGraphModel = asset.m_nodeGraphModel;
        }

        m_nodePropertiesRect = new Rect(propertiesRect.position.x + 5f, propertiesRect.position.y + 5f, propertiesRect.width - 10f, propertiesRect.height - 10f);
        BeginArea(m_nodePropertiesRect);
        if (selected_node != null) // if there has been a node selected, display that node's properties
        {
            int node_id = selected_node.m_id;
            Label("Node Properties");
            DialogueData data = m_nodeGraphModel.GetDataFromNodeID(node_id);
            if (data != null)
            {
                data.m_isStartNode = Toggle(data.m_isStartNode, "Is start node");
                Label(" ");

                Label("Character Speaking");
                data.characterName = TextArea(data.characterName);

                Label("Preview Text");
                data.previewDialogueText = TextArea(data.previewDialogueText, Height(50));

                Label("Dialogue Text");
                data.dialogueText = TextArea(data.dialogueText, Height(m_nodePropertiesRect.height * 0.5f));
            }

            if (m_nodeGraphModel != null)
            {
                if (Button("Add Dialogue Option"))
                {
                    m_nodeGraphModel.AddOutputPlugToNode(node_id);
                }
            }
        }
        else if (asset != null) // display asset properties
        {
            Label("Dialogue Asset");
            if (Button("Save Asset"))
            {
                // save asset
                asset.SaveAsset(m_nodeGraphModel);
            }
        }
        EndArea();
    }
예제 #3
0
    private void DisplayOptionNodeProperties(DialogueData data, int node_id, DialogueAssetBuilder asset)
    {
        // Error messages
        DisplayErrorMessages(data.node_id);

        //if (data.branchingIndex == 0)
        //    Label("False condition node", EditorStyles.boldLabel);
        //else if (data.branchingIndex == 1)
        //    Label("True condition node", EditorStyles.boldLabel);
        //else { Label("out index : " + data.branchingIndex.ToString()); }

        // get next dialogue nodes
        List <int> nextData    = asset.GetNextDialogueData(data, m_nodeGraphModel);
        int        optionIndex = 0;

        foreach (var nextid in nextData)
        {
            Node nextNode = m_nodeGraphModel.GetNodeFromID(nextid);
            if (nextNode != null)
            {
                DialogueData next = m_nodeGraphModel.GetDataFromNodeID(nextid);
                if (next != null)
                {
                    Label("Preview Text for option " + optionIndex.ToString());
                    next.previewDialogueText = TextArea(next.previewDialogueText, Height(50));
                }
            }
            optionIndex++;
        }

        if (data.m_isBranching && !data.isConditionalBranching)
        {
            if (m_nodeGraphModel != null)
            {
                if (Button("Add Dialogue Option"))
                {
                    m_nodeGraphModel.AddOutputPlugToNode(node_id);
                }
            }
        }
    }
예제 #4
0
    public void AddNode(Vector2 position)
    {
        int modelID = m_nodeGraphModel.AddNode(position);

        m_nodeGraphModel.AddOutputPlugToNode(modelID);
    }