示例#1
0
        private void LoadConfig(string json)
        {
            Players = new Dictionary <string, PlayerConfig>();

            var data = JObject.Parse(json);

            // Read the player configuration
            var playerConfigurations = data.SelectToken("players");

            foreach (var player in playerConfigurations)
            {
                var playerConfig = new PlayerConfig(player);
                var playerNum    = Players.Count + 1;
                Players.Add($"player{playerNum}", playerConfig);
            }

            // Read cost/cd info
            var gameInfo = data.SelectToken("gameInfo");

            CooldownsEnabled = (bool)gameInfo.SelectToken("COOLDOWNS_ENABLED");
            ManaCostsEnabled = (bool)gameInfo.SelectToken("MANACOSTS_ENABLED");

            // Read if chat commands are enabled
            ChatCheatsEnabled = (bool)gameInfo.SelectToken("CHEATS_ENABLED");

            // Read if minion spawns are enabled
            MinionSpawnsEnabled = (bool)gameInfo.SelectToken("MINION_SPAWNS_ENABLED");

            // Read the game configuration
            var game = data.SelectToken("game");

            GameConfig = new GameConfig(game);

            // Read spawns info
            ContentManager = ContentManager.LoadGameMode(GameConfig.GameMode);
            var mapPath = ContentManager.GetMapDataPath(GameConfig.Map);
            var mapData = JObject.Parse(File.ReadAllText(mapPath));
            var spawns  = mapData.SelectToken("spawns");

            MapSpawns = new MapSpawns();
            foreach (JProperty teamSpawn in spawns)
            {
                var team = teamSpawn.Name;
                var spawnsByPlayerCount = (JArray)teamSpawn.Value;
                for (var i = 0; i < spawnsByPlayerCount.Count; i++)
                {
                    var playerSpawns = new PlayerSpawns((JArray)spawnsByPlayerCount[i]);
                    MapSpawns.SetSpawns(team, playerSpawns, i);
                }
            }
        }
示例#2
0
        private void LoadConfig(string path)
        {
            Players = new Dictionary <string, PlayerConfig>();

            var data = JObject.Parse(File.ReadAllText(path));

            // Read the player configuration
            var playerConfigurations = data.SelectToken("players");

            foreach (var player in playerConfigurations)
            {
                var playerConfig = new PlayerConfig(player);
                Players.Add(string.Format("player{0}", Players.Count + 1), playerConfig);
            }

            //Read cost/cd info
            var spellInfo = data.SelectToken("spellInfo");

            CooldownsDisabled = (bool)spellInfo.SelectToken("NO_COOLDOWN");
            ManaCostsDisabled = (bool)spellInfo.SelectToken("NO_MANACOST");

            // Read the game configuration
            var game = data.SelectToken("game");

            GameConfig = new GameConfig(game);

            // Read spawns info
            ContentManager = ContentManager.LoadGameMode(GameConfig.GameMode);
            var mapPath = ContentManager.GetMapDataPath(GameConfig.Map);
            var mapData = JObject.Parse(File.ReadAllText(mapPath));
            var spawns  = mapData.SelectToken("spawns");

            MapSpawns = new MapSpawns();
            foreach (JProperty teamSpawn in spawns)
            {
                var team = teamSpawn.Name;
                var spawnsByPlayerCount = (JArray)teamSpawn.Value;
                for (var i = 0; i < spawnsByPlayerCount.Count; i++)
                {
                    var playerSpawns = new PlayerSpawns((JArray)spawnsByPlayerCount[i]);
                    MapSpawns.SetSpawns(team, playerSpawns, i);
                }
            }
        }