public Dictionary <int, Enemy> GetDict() { XElement ec = EnemyContainer.Load(path); EnemyInfos = ec.Element("Enemies").Elements("Enemy").Select(c => new Enemy().Set(c)).ToDictionary(info => info.id); return(EnemyInfos); }
public Dictionary <int, Level> GetDict() { XElement lc = EnemyContainer.Load(path); LevelInfos = lc.Element("Levels").Elements("Level").Select(c => new Level().Set(c)).ToDictionary(info => info.id); return(LevelInfos); }
void Start() { // Path that leads to the asset folder var xmlPath = Application.dataPath + "/enemies.xml"; // Load function from the EnemyContainer class, passing in the path to which xml file to load var xmldat = EnemyContainer.Load(xmlPath); Debug.Log("Name: " + xmldat.Enemies[0].Name); Debug.Log("Health: " + xmldat.Enemies[0].Health); Debug.Log("Level: " + xmldat.Enemies[0].Level); Debug.Log(xmldat.Enemies[1].Nested[0].Boss); Debug.Log(xmldat.Enemies [1].Nested [0].Name); Debug.Log(xmldat.Enemies [0]); //////////////xmldat.Enemies [0].Health = 200; /////////////xmldat.Enemies [0].Name = "Steven"; //Save function - this updates and overwrites the current xml//xmldat.Save(Path.Combine(Application.dataPath, "enemies.xml")); }
public void Init() { XElement ec = EnemyContainer.Load(path); EnemyInfos = ec.Element("Enemies").Elements("Enemy").Select(c => new Enemy().Set(c)).ToDictionary(info => info.id); }