public void Initialize(Data.Map.Team[] mapTeams, IReadOnlyList <Player> players) { _teamTemplatesById.Clear(); _teamTemplatesByName.Clear(); foreach (var mapTeam in mapTeams) { var name = mapTeam.Properties["teamName"].Value as string; var ownerName = mapTeam.Properties["teamOwner"].Value as string; var owner = players.FirstOrDefault(player => player.Name == ownerName); var isSingleton = (bool)mapTeam.Properties["teamIsSingleton"].Value; var id = (uint)(_teamTemplatesById.Count + 1); var teamTemplate = new TeamTemplate( id, name, owner, isSingleton); _teamTemplatesById.Add(id, teamTemplate); _teamTemplatesByName.Add(name, teamTemplate); } }
internal Team AddTeam(TeamTemplate teamTemplate) { _lastTeamId++; var team = new Team(teamTemplate, _lastTeamId); teamTemplate.AddTeam(team); return(team); }
internal Team AddTeamWithId(TeamTemplate teamTemplate, uint id) { _lastTeamId = Math.Max(_lastTeamId, id); var team = new Team(teamTemplate, id); teamTemplate.AddTeam(team); return(team); }
private void AddTeamTemplate(string name, Player owner, bool isSingleton) { var id = (uint)(_teamTemplatesById.Count + 1); var teamTemplate = new TeamTemplate( this, id, name, owner, isSingleton); _teamTemplates.Add(teamTemplate); _teamTemplatesById.Add(id, teamTemplate); _teamTemplatesByName.Add(name, teamTemplate); if (isSingleton) { AddTeam(teamTemplate); } }
internal Team(TeamTemplate template, uint id) { Template = template; Id = id; }