Beispiel #1
0
        public static LevelFormat GetLevelData(string levelId)
        {
            if (levelId.Length == 0)
            {
                return(null);
            }
            levelId = levelId.ToUpper();

            // Make sure the level exists:
            string fullLevelPath = LevelContent.GetFullLevelPath(levelId);

            if (!File.Exists(fullLevelPath))
            {
                return(null);
            }

            string json = File.ReadAllText(fullLevelPath);

            // If there is no JSON content, end the attempt to load level:
            if (json == "")
            {
                return(null);
            }

            // Load the Data
            return(JsonConvert.DeserializeObject <LevelFormat>(json));
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        // Verify that the level exists in the level directory.
        public static bool LevelExists(string levelId)
        {
            levelId = levelId.ToUpper();
            string fullLevelPath = LevelContent.GetFullLevelPath(levelId);

            return(File.Exists(fullLevelPath));
        }