Ejemplo n.º 1
0
        public Level(LocalLevel level)
        {
            LocalLevel  = level;
            LevelString = DecompressLevel(level.LevelString);

            ParseObjects();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Decompresses a level's string.
        /// </summary>
        /// <param name="level">A local level.</param>
        /// <returns>The decompressed level string.</returns>
        public static string DecompressLevel(LocalLevel level)
        {
            if (!level.LevelString.StartsWith("H4sIAAAAAAAA"))
            {
                throw new ArgumentException("The provided level string is invalid.");
            }

            return(Encoding.ASCII.GetString(GameManager.Decompress(Base64.DecodeToBytes(level.LevelString))));
        }
Ejemplo n.º 3
0
        public static LocalLevel Load(string levelString)
        {
            var lvl   = new LocalLevel();
            var props = typeof(LocalLevel).GetProperties();

            foreach (var prop in props)
            {
                var attrs = prop.GetCustomAttributes(false);

                foreach (var attr in attrs)
                {
                    if (attr is GdXmlAttribute gdattr)
                    {
                        prop.SetValue(lvl, LocalLevelManager.GetPair(levelString, gdattr.Key, prop.PropertyType).Value);
                    }
                }
            }

            return(lvl);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// A way to load a level.
        /// </summary>
        /// <param name="localLevel">Loads over a <see cref="LocalLevel" /> instance.</param>
        /// <returns>A parsed level.</returns>
        public static Level Load(LocalLevel localLevel)
        {
            var level = new Level(localLevel);

            return(level);
        }