Esempio n. 1
0
            internal static Level TryGetTemplateLevel(string text)
            {
                if (text == null)
                {
                    throw new SettingsException("The level template is null.");
                }

                if (File.Exists(text))
                {
                    try
                    {
                        var template = Level.FromPath(text);
                        template.Path = null;
                        return(template);
                    }
                    catch (Exception)
                    {
                        throw new SettingsException("The level template file is not a valid Elma level file.");
                    }
                }

                var regex = new Regex(@"^(\d+),(\d+)$");

                if (!regex.IsMatch(text))
                {
                    throw new SettingsException(
                              "The level template is neither a file nor a string of the form \"width,height\".");
                }

                double width  = int.Parse(regex.Match(text).Groups[1].Value);
                double height = int.Parse(regex.Match(text).Groups[2].Value);

                return(Level.FromDimensions(width, height));
            }
Esempio n. 2
0
        internal Level GetLevel()
        {
            if (LevelExists)
            {
                if (IsInternal)
                {
                    while (Global.Internals == null)
                    {
                    }

                    return(Global.Internals[_internalIndex - 1]);
                }

                return(Level.FromPath(LevelPath));
            }

            throw new FileNotFoundException("The level file does not exist!", LevelFilename);
        }