Ejemplo n.º 1
0
    // Reads and Serializes a specific XML file
    private void LoadXmlFileData(string fileName)
    {
        string xmlPath = Path.Combine(xmlDirectory, fileName);

        if (Path.GetExtension(xmlPath) == string.Empty)
        {
            xmlPath += ".xml";
        }
        else if (Path.GetExtension(xmlPath) != ".xml")
        {
            Path.ChangeExtension(xmlPath, ".xml");
        }

        if (File.Exists(Path.Combine(Application.dataPath, xmlPath)))
        {
            currentSceneDialog = XML_Loader.Deserialize <SceneDialogs> ((Path.Combine(Application.dataPath, xmlPath)));
            if (currentSceneDialog.allDialogsInScene [0] != null)
            {
                SelectDialogByID(0);
                selectedDialogLine = null;

                /*if (selectedDialog.DialogLines.Count != 0) {
                 *      SelectDialogLine (0);
                 * }*/
            }
        }
        else
        {
            Debug.LogError("XML File: " + (Path.Combine(Application.dataPath, xmlPath)) + " is not found.");
        }
    }
Ejemplo n.º 2
0
    private void SafeToXMLFile()
    {
        // Making sure the file directory exists
        if (!AssetDatabase.IsValidFolder(xmlDirectory))
        {
            Directory.CreateDirectory(Path.Combine(Application.dataPath, xmlDirectory));
        }

        // Making sure the given file-name is legit
        string path = Path.Combine(Application.dataPath, Path.Combine(xmlDirectory, selectedSceneName));

        if (Path.GetExtension(path) == string.Empty)
        {
            path += ".xml";
        }
        else if (Path.GetExtension(path) != ".xml")
        {
            Path.ChangeExtension(path, ".xml");
        }

        XML_Loader.Serialize(currentSceneDialog, path);
    }
Ejemplo n.º 3
0
    // Loads the Dialogs out of an XML file from "Resources/XML_Files/SceneDialogs", and the passed file name.
    // This is called during OnNewLevelLoaded function in the GameManager
    public void LoadDialog(string fileName)
    {
        //Creates a path to an xml file, and only an xml file.
        string xmlPath = Path.Combine("Resources/XML_Files/SceneDialogs", fileName);

        if (Path.GetExtension(xmlPath) == string.Empty)
        {
            xmlPath += ".xml";
        }
        else if (Path.GetExtension(xmlPath) != ".xml")
        {
            Path.ChangeExtension(xmlPath, ".xml");
        }

        if (File.Exists(Path.Combine(Application.dataPath, xmlPath)))
        {
            sceneDialogs = XML_Loader.Deserialize <SceneDialogs> ((Path.Combine(Application.dataPath, xmlPath)));
        }
        else
        {
            Debug.LogError("XML File: " + (Path.Combine(Application.dataPath, xmlPath)) + " is not found.");
        }
    }