Ejemplo n.º 1
0
 public void SetSpawns(string team, PlayerSpawns spawns, int playerCount)
 {
     if (team.ToLower().Equals("blue"))
     {
         Blue[playerCount] = spawns;
     }
     else
     {
         Purple[playerCount] = spawns;
     }
 }
Ejemplo n.º 2
0
        private void LoadConfig(Game game, 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 where the content is
            ContentPath = (string)gameInfo.SelectToken("CONTENT_PATH");

            // Read global damage text setting
            IsDamageTextGlobal = (bool)gameInfo.SelectToken("IS_DAMAGE_TEXT_GLOBAL");

            // Load items
            game.ItemManager.AddItems(ItemContentCollection.LoadItemsFrom(
                                          // todo: remove this hardcoded path with content pipeline refactor
                                          $"{ContentPath}/LeagueSandbox-Default/Items"
                                          ));

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

            GameConfig = new GameConfig(gameToken);

            // Read spawns info
            ContentManager = ContentManager.LoadGameMode(game, GameConfig.GameMode, ContentPath);
            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);
                }
            }
        }