Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System.Xml;
- using System.Xml.Serialization;
- using System.IO;
- public class Lang
- {
- [XmlAttribute("id")]
- public int id;
- [XmlAttribute("txt")]
- public string txt;
- }
- public class Quip
- {
- [XmlAttribute("id")]
- public int id;
- [XmlAttribute("txt")]
- public string txt;
- [XmlAttribute("death")]
- public int death = 0;
- [XmlAttribute("wpn")]
- public int wpn = -1;
- [XmlAttribute("acc")]
- public int acc = -1;
- }
- [XmlRoot("langues")]
- public class LANG
- {
- [XmlElement("Language")]
- public Language items;
- }
- public class Language
- {
- [XmlElement("lang")] public List<Lang> langs = new List<Lang>();
- [XmlArray("Quips"), XmlArrayItem("quip")]
- public List<Quip> quips = new List<Quip>();
- public static Language Load(string path)
- {
- TextAsset _xml = Resources.Load<TextAsset>(path);
- XmlSerializer serializer = new XmlSerializer(typeof(LANG));
- StringReader reader = new StringReader(_xml.text);
- LANG lan = serializer.Deserialize(reader) as LANG;
- Debug.Log(lan.items.langs.Count);
- reader.Close();
- return lan.items;
- }
- public static string TXT(int ID)
- {
- string path = "language";
- Language lang = Language.Load(path);
- int count = lang.langs.Count;
- if(count == 0 || ID > count-1) return null;
- return lang.langs[ID].txt;
- }
- public static Quip[] QUIP()
- {
- string path = "language";
- Language lang = Language.Load(path);
- return lang.quips.ToArray();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment