public bool LoadLevelData(string levelId = "") { levelId = levelId.ToUpper(); // Update the Level ID, or use existing Level ID if applicable. if (levelId.Length > 0) { this.levelId = levelId; } else { return(false); } string fullLevelPath = LevelContent.GetFullLevelPath(this.levelId); // Make sure the level exists: if (!File.Exists(fullLevelPath)) { return(false); } string json = File.ReadAllText(fullLevelPath); // If there is no JSON content, end the attempt to load level: if (json == "") { return(false); } // Load the Data this.data = JsonConvert.DeserializeObject <LevelFormat>(json); return(true); }
public static LevelFormat BuildEmptyLevel(string levelId) { LevelFormat level = new LevelFormat { id = levelId.ToUpper(), account = "", title = "Unnamed Level", description = "", gameClass = (byte)GameClassFlag.LevelStandard, timeLimit = 300, music = (byte)MusicTrack.None, icon = new byte[] { 0, 0, 0, 0, 0 }, rooms = new List <RoomFormat>() { LevelContent.BuildRoomData() } }; return(level); }
public bool LoadLevelData(LevelFormat levelData) { this.data = levelData; this.levelId = levelData.id.ToUpper(); return(true); }