Example #1
0
        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);
            }
        }
Example #2
0
        internal Team AddTeam(TeamTemplate teamTemplate)
        {
            _lastTeamId++;

            var team = new Team(teamTemplate, _lastTeamId);

            teamTemplate.AddTeam(team);

            return(team);
        }
Example #3
0
        internal Team AddTeamWithId(TeamTemplate teamTemplate, uint id)
        {
            _lastTeamId = Math.Max(_lastTeamId, id);

            var team = new Team(teamTemplate, id);

            teamTemplate.AddTeam(team);

            return(team);
        }
Example #4
0
        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);
            }
        }
Example #5
0
 internal Team(TeamTemplate template, uint id)
 {
     Template = template;
     Id       = id;
 }