private void PopulateDialogueList(NodeGraphModel model_data)
    {
        m_dialogueAsset.m_dialogueData = new Dictionary <int, DialogueData>();

        foreach (KeyValuePair <int, DialogueData> dialogue_pair in model_data.GetDialogueData())
        {
            List <NextDialogueDataContent> nextData = new List <NextDialogueDataContent>();
            DialogueData dialogue = dialogue_pair.Value;
            // populating next branch ids
            dialogue.m_isBranching      = model_data.GetNodeFromID(dialogue.node_id).m_outputPlugs.Count > 1;
            dialogue.m_nextDialogueData = new List <int>();
            foreach (KeyValuePair <int, Connection> connection_pair in model_data.GetConnections())
            {
                Connection connection = connection_pair.Value;
                if (connection.m_outputNodeId == dialogue.node_id)
                {
                    // adding branching indices
                    DialogueData            next_data       = model_data.GetDataFromNodeID(connection.m_inputNodeId);
                    NextDialogueDataContent nextDataContent = new NextDialogueDataContent();

                    if (next_data.branchingIndex == -1)
                    {
                        Plug outputplug_index = model_data.GetNodeFromID(connection.m_outputNodeId).m_outputPlugs[connection.m_outputPlugId];
                        Debug.Log(outputplug_index.m_plugIndex);
                        next_data.branchingIndex = outputplug_index.m_plugIndex;
                    }

                    nextDataContent.branchingIndex = next_data.branchingIndex;
                    nextDataContent.nextNodeIndex  = connection.m_inputNodeId;
                    nextData.Add(nextDataContent);
                }
            }

            nextData.Sort(delegate(NextDialogueDataContent c1, NextDialogueDataContent c2) { return(c1.branchingIndex.CompareTo(c2.branchingIndex)); });
            foreach (NextDialogueDataContent next_data in nextData)
            {
                dialogue.m_nextDialogueData.Add(next_data.nextNodeIndex);
            }

            // sort the next dialogue data by index;
            m_dialogueAsset.m_dialogueData.Add(dialogue.node_id, dialogue);
        }
    }
示例#2
0
 public Node GetSelectedNode()
 {
     // return the first selected node for the node properities view
     if (m_nodeIDsSelected.Count != 0)
     {
         return(m_nodeGraphModel.GetNodeFromID(m_nodeIDsSelected[0]));
     }
     return(null);
 }
示例#3
0
    private void PopulateDialogueList(NodeGraphModel model_data)
    {
        m_dialogueAsset.m_dialogueData = new Dictionary <int, DialogueData>();

        foreach (KeyValuePair <int, DialogueData> dialogue_pair in model_data.GetDialogueData())
        {
            DialogueData dialogue = dialogue_pair.Value;
            // populating next branch ids
            dialogue.m_isBranching      = model_data.GetNodeFromID(dialogue.node_id).m_outputPlugs.Count > 1;
            dialogue.m_nextDialogueData = new List <int>();
            foreach (KeyValuePair <int, Connection> connection_pair in model_data.GetConnections())
            {
                Connection connection = connection_pair.Value;
                if (connection.m_outputNodeId == dialogue.node_id)
                {
                    dialogue.m_nextDialogueData.Add(connection.m_inputNodeId);
                }
            }
            m_dialogueAsset.m_dialogueData.Add(dialogue.node_id, dialogue);
        }
    }
    public List <int> GetNextDialogueData(DialogueData data, NodeGraphModel model_data)
    {
        List <NextDialogueDataContent> nextData = new List <NextDialogueDataContent>();
        DialogueData dialogue = data;

        // populating next branch ids
        dialogue.m_nextDialogueData = new List <int>();
        foreach (KeyValuePair <int, Connection> connection_pair in model_data.GetConnections())
        {
            Connection connection = connection_pair.Value;
            if (connection.m_outputNodeId == dialogue.node_id)
            {
                // adding branching indices
                DialogueData            next_data       = model_data.GetDataFromNodeID(connection.m_inputNodeId);
                NextDialogueDataContent nextDataContent = new NextDialogueDataContent();

                if (next_data.branchingIndex == -1)
                {
                    Plug outputplug_index = model_data.GetNodeFromID(connection.m_outputNodeId).m_outputPlugs[connection.m_outputPlugId];
                    Debug.Log(outputplug_index.m_plugIndex);
                    next_data.branchingIndex = outputplug_index.m_plugIndex;
                }
                nextDataContent.branchingIndex = next_data.branchingIndex;
                nextDataContent.nextNodeIndex  = connection.m_inputNodeId;
                nextData.Add(nextDataContent);
            }
        }

        nextData.Sort(delegate(NextDialogueDataContent c1, NextDialogueDataContent c2) { return(c1.branchingIndex.CompareTo(c2.branchingIndex)); });
        foreach (NextDialogueDataContent next_data in nextData)
        {
            dialogue.m_nextDialogueData.Add(next_data.nextNodeIndex);
        }

        return(dialogue.m_nextDialogueData);
    }
示例#5
0
 public void AddConditionalNode(Vector2 position)
 {
     int  modelID   = m_nodeGraphModel.AddConditionalNode(position);
     Node cond_node = m_nodeGraphModel.GetNodeFromID(modelID);
 }
    public void DrawNodeProperties(Rect propertiesRect, List <int> selected_nodes, 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);
        scrollPosition = BeginScrollView(scrollPosition, false, false, Width(m_nodePropertiesRect.width), Height(m_nodePropertiesRect.height));

        EditorGUI.BeginChangeCheck();

        if (SceneManager.GetActiveScene().name == asset.m_dialogueAsset.SceneName)
        {
            // display first node properties
            if (selected_nodes != null) // if there has been a node selected, display that node's properties
            {
                Node first_node = m_nodeGraphModel.GetNodeFromID(selected_nodes[0]);
                int  node_id    = first_node.m_id;
                Label("Node Properties", EditorStyles.boldLabel);
                DialogueData data = m_nodeGraphModel.GetDataFromNodeID(node_id);
                if (data != null)
                {
                    // draw start node
                    if (data.m_isStartNode)
                    {
                        DisplayStartNodeProperties(data, node_id);
                    }
                    // draw condition node
                    else if (data.isConditionalBranching)
                    {
                        DisplayConditionalNodeProperties(data, node_id, asset);
                    }
                    // draw option node
                    else if (data.m_isBranching && !data.isConditionalBranching)
                    {
                        DisplayOptionNodeProperties(data, node_id, asset);
                    }
                    else if (data.m_isEventNode)
                    {
                        DisplayEventNode(data);
                    }
                    // draw normal node
                    else
                    {
                        DisplayNormalNodeProperties(data, asset);
                    }
                }
            }
            else if (asset != null) // display asset properties
            {
                DisplayAssetProperties(asset);
                // cheat sheet for the tags in the markup so far
                {
                    DisplayMarkupCheatSheet();
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(asset.m_dialogueAsset, "");
            }
        }
        else
        {
            Label("Used in Scene :" + asset.m_dialogueAsset.SceneName, EditorStyles.boldLabel);
            Label("Asset locked and not editable because you are in the incorrect scene");

            Label("", EditorStyles.boldLabel);
            Label("", EditorStyles.boldLabel);
            Label("ONLY DO THIS IF YOU'RE SURE", EditorStyles.boldLabel);
            if (Button("Change Asset to Current Scene"))
            {
                asset.m_dialogueAsset.SceneName = SceneManager.GetActiveScene().name;
            }
        }
        EndScrollView();
        EndArea();
    }