public void LoadEditorSaveData()
    {
        m_nodeGraphModel = new NodeGraphModel();

        string[] data       = m_dialogueAsset.m_assetData.Split("`".ToCharArray());
        int      data_index = 0;

        if (data.Length <= 1) // no data in the asset at the moment
        {
            return;
        }

        // load connections
        int connectionCount = int.Parse(data[data_index++]);

        for (int connection_index = 0; connection_index < connectionCount; ++connection_index)
        {
            Connection connection = new Connection();
            connection.m_id           = int.Parse(data[data_index++]);
            connection.m_inputNodeId  = int.Parse(data[data_index++]);
            connection.m_outputNodeId = int.Parse(data[data_index++]);
            connection.m_inputPlugId  = int.Parse(data[data_index++]);
            connection.m_outputPlugId = int.Parse(data[data_index++]);
            m_nodeGraphModel.AddConnection(connection);
        }

        // load nodes
        int node_count = int.Parse(data[data_index++]);

        for (int node_index = 0; node_index < node_count; ++node_index)
        {
            Node node = new Node();
            node.m_id              = int.Parse(data[data_index++]);
            node.m_position        = new Vector2();
            node.m_position.x      = float.Parse(data[data_index++]); node.m_position.y = float.Parse(data[data_index++]);
            node.m_dimension       = new Vector2();
            node.m_dimension.x     = float.Parse(data[data_index++]); node.m_dimension.y = float.Parse(data[data_index++]);
            node.isConditionalNode = bool.Parse(data[data_index++]);
            node.m_inputPlug       = LoadInputPlug(data, ref data_index, PlugType.kIn);
            int output_plug_count = int.Parse(data[data_index++]);
            node.m_outputPlugs = new Dictionary <int, Plug>();
            for (int i = 0; i < output_plug_count; ++i)
            {
                Plug out_plug = LoadInputPlug(data, ref data_index, PlugType.kOut);
                node.m_outputPlugs.Add(out_plug.m_plugId, out_plug);
            }
            m_nodeGraphModel.AddNode(node);
        }

        // edit here when dialogue data changes
        for (int dialogue_index = 0; dialogue_index < m_dialogueAsset.m_runtimeBuiltData.Count; ++dialogue_index)
        {
            DialogueData dialogue = m_dialogueAsset.m_runtimeBuiltData[dialogue_index];
            dialogue.eventObjects = new List <GameObject>();
            for (int i = 0; i < dialogue.eventObjectNames.Count; ++i)
            {
                dialogue.eventObjects.Add(m_dialogueAsset.FindGameObject(dialogue.eventObjectNames[i]));
            }
            m_nodeGraphModel.AddDialogueData(dialogue);
        }
        m_nodeGraphModel.startNodeID = m_dialogueAsset.m_startIndex;
        //updating involved characters gameobject list
        m_dialogueAsset.LoadCharactersInvolvedGameObjects();
    }
Exemple #2
0
    public void LoadEditorSaveData()
    {
        m_nodeGraphModel = new NodeGraphModel();

        string[] data       = m_dialogueAsset.m_assetData.Split("`".ToCharArray());
        int      data_index = 0;

        if (data.Length <= 1) // no data in the asset at the moment
        {
            return;
        }

        // load connections
        int connectionCount = int.Parse(data[data_index++]);

        for (int connection_index = 0; connection_index < connectionCount; ++connection_index)
        {
            Connection connection = new Connection();
            connection.m_id           = int.Parse(data[data_index++]);
            connection.m_inputNodeId  = int.Parse(data[data_index++]);
            connection.m_outputNodeId = int.Parse(data[data_index++]);
            connection.m_inputPlugId  = int.Parse(data[data_index++]);
            connection.m_outputPlugId = int.Parse(data[data_index++]);
            m_nodeGraphModel.AddConnection(connection);
        }

        // load nodes
        int node_count = int.Parse(data[data_index++]);

        for (int node_index = 0; node_index < node_count; ++node_index)
        {
            Node node = new Node();
            node.m_id          = int.Parse(data[data_index++]);
            node.m_position    = new Vector2();
            node.m_position.x  = float.Parse(data[data_index++]); node.m_position.y = float.Parse(data[data_index++]);
            node.m_dimension   = new Vector2();
            node.m_dimension.x = float.Parse(data[data_index++]); node.m_dimension.y = float.Parse(data[data_index++]);
            node.m_inputPlug   = LoadInputPlug(data, ref data_index, PlugType.kIn);
            int output_plug_count = int.Parse(data[data_index++]);
            node.m_outputPlugs = new Dictionary <int, Plug>();
            for (int i = 0; i < output_plug_count; ++i)
            {
                Plug out_plug = LoadInputPlug(data, ref data_index, PlugType.kOut);
                node.m_outputPlugs.Add(out_plug.m_plugId, out_plug);
            }
            m_nodeGraphModel.AddNode(node);
        }

        // edit here when dialogue data changes
        // load dialogue data (for editor use)
        int dialogue_count = int.Parse(data[data_index++]);

        for (int dialogue_index = 0; dialogue_index < dialogue_count; ++dialogue_index)
        {
            DialogueData dialogue = new DialogueData();
            dialogue.node_id             = int.Parse(data[data_index++]);
            dialogue.characterName       = data[data_index++];
            dialogue.dialogueText        = data[data_index++];
            dialogue.previewDialogueText = data[data_index++];
            dialogue.m_isStartNode       = bool.Parse(data[data_index++]);
            m_nodeGraphModel.AddDialogueData(dialogue);
        }
    }