/// <summary> /// Load Level Collection. /// </summary> /// <param name="path">QFC file path</param> /// <returns></returns> public static LevelCollection LoadLevels(string path) { LevelCollection collection = new LevelCollection(); using (var stream = TitleContainer.OpenStream(path)) { XDocument doc = XDocument.Load(stream); XElement root = doc.Element("collection"); #region Load Levels foreach (XElement el in root.Element("levels").Elements("level")) { int id = int.Parse(el.Attribute("id").Value); int[] neighbors = (from string element in el.Attribute("neighbors").Value.Split(',') select int.Parse(element)).ToArray <int>(); Level level = LoadMap(id, el.Attribute("path").Value); level.BGM = el.Attribute("music").Value; level.Title = el.Attribute("title").Value; for (int i = 0; i < 4; i++) { level.SetNeighbor((Direction)i, neighbors[i]); } collection.AddLevel(level); } #endregion Load Levels } return(collection); }
private void SaveLevel() { LevelData editData = new LevelData( _LevelID, _Width, _Height, _LinkerColors, _TargetScore, _Moves ); if (_LevelCollection.AddLevel(editData)) { SaveSystem.SaveLevels(_LevelCollection._StoredLevels); ReloadLevelCollection(); } }