Exemplo n.º 1
0
        public static void OutputGBAJSONForWeb(string dir, GameModeSelection mode)
        {
            var dirName  = Path.GetFileName(dir);
            var name     = dirName.Substring(0, dirName.LastIndexOf('_'));
            var settings = new GameSettings(mode, dir, 1, 1);

            var m = settings.GetGameManager;

            var worlds = m.GetLevels(settings).First().Worlds;

            var jsonObj = new
            {
                name   = $"{mode.GetAttribute<GameModeAttribute>().DisplayName.Replace(" - EU", "").Replace(" - US", "").Replace(" - EU 1", "").Replace(" - EU 2", "")}",
                mode   = mode.ToString(),
                folder = $"gba/{dirName}",
                levels = worlds.Select(w => w.Maps.OrderBy(x => x).Select(lvl => new
                {
                    world        = w.Index,
                    level        = lvl,
                    nameInternal = $"{lvl}",
                    name         = $"Map {lvl}"
                })).SelectMany(x => x)
            };

            var outDir = Path.Combine(Path.GetDirectoryName(dir), "JSON", name);

            Directory.CreateDirectory(outDir);

            JsonHelpers.SerializeToFile(jsonObj, Path.Combine(outDir, $"{dirName.Substring(name.Length + 1)}.json"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="gameModeSelection">The game mode selection</param>
        /// <param name="gameDirectory">The game directory</param>
        /// <param name="world">The game world</param>
        /// <param name="level">The game level, starting at 1</param>
        public GameSettings(GameModeSelection gameModeSelection, string gameDirectory, int world, int level)
        {
            // Get the attribute data
            var atr = gameModeSelection.GetAttribute <GameModeAttribute>();

            GameModeSelection = gameModeSelection;
            Game               = atr.Game;
            EngineVersion      = atr.EngineVersion;
            MajorEngineVersion = atr.MajorEngineVersion;
            GameDirectory      = Util.NormalizePath(gameDirectory, isFolder: true);
            World              = world;
            Level              = level;
        }