public static AreaDataContainer CreateFromXml(XElement dataSource) { AreaDataContainer container = new AreaDataContainer( dataSource.Attribute("name").Value, dataSource.Attribute("selection-texture").Value, dataSource.Attribute("difficulty-tag").Value, (int)dataSource.Attribute("speed-step"), (int)dataSource.Attribute("level-count")); if (dataSource.Attribute("last-level") != null) { container.LastSelectedLevel = (int)dataSource.Attribute("last-level"); } if (dataSource.Attribute("locked") != null) { container.Locked = (bool)dataSource.Attribute("locked"); } if (dataSource.Attribute("no-race") != null) { container.DoesNotHaveRaceCourse = (bool)dataSource.Attribute("no-race"); } if (dataSource.Element("completion-unlockables") != null) { container.SetAreaCompletionUnlockables(dataSource.Element("completion-unlockables")); } if ((dataSource.Element("scores") != null) && (dataSource.Element("scores").Elements("score") != null)) { foreach (XElement s in dataSource.Element("scores").Elements("score")) { container.LevelScores.Add((int)s); } } if ((dataSource.Element("rankings") != null) && (dataSource.Element("rankings").Elements("rank") != null)) { foreach (XElement r in dataSource.Element("rankings").Elements("rank")) { Definitions.SurvivalRank rank = (Definitions.SurvivalRank)Enum.Parse(typeof(Definitions.SurvivalRank), r.Value); container.LevelRanks.Add(rank); } } if (dataSource.Element("tickets-from-level") != null) { container.SetCollectedTicketsFromLevel(dataSource.Element("tickets-from-level")); } if (dataSource.Element("tickets-from-crates") != null) { container.SetCollectedTicketsFromCrates(dataSource.Element("tickets-from-crates")); } return(container); }
private void LoadAreaDataFromXml(XElement areaData) { if (areaData != null) { _areaLevelData.Clear(); foreach (XElement a in areaData.Elements("area")) { _areaLevelData.Add(a.Attribute("name").Value, AreaDataContainer.CreateFromXml(a)); } } }
private void CreateAreaData(XDocument areaData) { foreach (XElement el in areaData.Element("areas").Elements("area")) { if (!_areaLevelData.ContainsKey(el.Attribute("name").Value)) { _areaLevelData.Add(el.Attribute("name").Value, AreaDataContainer.CreateFromXml(el)); } else if (el.Element("completion-unlockables") != null) { _areaLevelData[el.Attribute("name").Value].SetCompletionUnlockables(el.Element("completion-unlockables")); } } }
public static AreaDataContainer CreateFromXml(XElement dataSource) { AreaDataContainer container = new AreaDataContainer( dataSource.Attribute("name").Value, dataSource.Attribute("selection-texture").Value, dataSource.Attribute("difficulty-tag").Value, (int)dataSource.Attribute("speed-step"), (int)dataSource.Attribute("level-count")); if (dataSource.Attribute("last-level") != null) { container.LastSelectedLevel = (int)dataSource.Attribute("last-level"); } if (dataSource.Attribute("locked") != null) { container.Locked = (bool)dataSource.Attribute("locked"); } if (dataSource.Attribute("no-race") != null) { container.DoesNotHaveRaceCourse = (bool)dataSource.Attribute("no-race"); } if (dataSource.Element("completion-unlockables") != null) { container.SetAreaCompletionUnlockables(dataSource.Element("completion-unlockables")); } if ((dataSource.Element("scores") != null) && (dataSource.Element("scores").Elements("score") != null)) { foreach (XElement s in dataSource.Element("scores").Elements("score")) { container.LevelScores.Add((int)s); } } if ((dataSource.Element("rankings") != null) && (dataSource.Element("rankings").Elements("rank") != null)) { foreach (XElement r in dataSource.Element("rankings").Elements("rank")) { Definitions.SurvivalRank rank = (Definitions.SurvivalRank)Enum.Parse(typeof(Definitions.SurvivalRank), r.Value); container.LevelRanks.Add(rank); } } if (dataSource.Element("tickets-from-level") != null) { container.SetCollectedTicketsFromLevel(dataSource.Element("tickets-from-level")); } if (dataSource.Element("tickets-from-crates") != null) { container.SetCollectedTicketsFromCrates(dataSource.Element("tickets-from-crates")); } return container; }