Example #1
0
        /// <summary>
        /// Carga un string desde el fichero xml teniendo en cuenta el idioma seleccionado en la configuracion.
        /// </summary>
        /// <param name="tag">Identificador del texto tutorial a cargar</param>
        /// <returns>string deseado</returns>
        private static string LoadString(TUTORIAL_TXT_TAG tutorial)
        {
            TextAsset   txtXml;
            XmlDocument doc = new XmlDocument();
            XmlNode     node;

            try
            {
                txtXml = Resources.Load <TextAsset>("texts/" + GetStringsFileNameByLanguage());  //Obtiene el fichero xml en funcion del idioma
                doc.LoadXml(txtXml.text);                                                        //Carga el documento xml

                node = doc.DocumentElement.SelectSingleNode("//string[@id='" + tutorial + "']"); //Obtiene el nodo con Xpath

                return(node.InnerText);
            }
            catch (NullReferenceException nre)
            {
                Debug.LogError("No se ha encontrado el fichero xml del idioma: " + GameManager.Instance.Data.Language +
                               "\n" + nre.ToString() + ", " + nre.HelpLink);
                return("");
            }
        }
Example #2
0
 /// <summary>
 /// Devuelve los textos de los tutoriales
 /// </summary>
 /// <param name="tag"></param>
 /// <returns></returns>
 public static string GetTutorialString(TUTORIAL_TXT_TAG tag)
 {
     try
     {
         return(tutorialsDictionary[tag]);
     }
     catch (KeyNotFoundException knfe)
     {
         LoadGlobalDataTexts();
         Debug.LogWarning("No se pudo encontrar el string en el diccionario" +
                          "\nSe ha producido una excepcion: " + knfe.ToString() +
                          "\n" + knfe.HelpLink + " KEY: " + tag +
                          "\nSe han cargado los textos de nuevo.");
         return(tutorialsDictionary[tag]);
     }
     catch (Exception e)
     {
         Debug.LogError("Se ha intentado acceder a los datos de un nivel sin inicializarlo antes. ~.~\"\n"
                        + e.ToString() + " " + e.HelpLink);
         return("0");
     }
 }