public static void PlayerJoined(int _playerId, string _playerName) { Vector2 _newPlayerPosition; ETeam _teamId; CharacterObject obj; //Add player to a team if (TeamManager.centauriTeam.GetNrOfPlayers() <= TeamManager.marineTeam.GetNrOfPlayers()) { _newPlayerPosition = Map.mapPosition + new Vector2(map.getAlienSpawnPoint().X, map.getAlienSpawnPoint().Y); TeamManager.centauriTeam.AddPlayer(_playerId); _teamId = TeamManager.centauriTeam.GetTeamId(); obj = new RoachObject(_playerId, _newPlayerPosition); } else { _newPlayerPosition = Map.mapPosition + new Vector2(map.getMarineSpawnPoint().X, map.getMarineSpawnPoint().Y); TeamManager.marineTeam.AddPlayer(_playerId); _teamId = TeamManager.marineTeam.GetTeamId(); obj = new MarineObject(_playerId, _newPlayerPosition); } Player newPlayer = new Player(_playerId, _playerName, _teamId); newPlayer.gameObj = obj; players.Add(_playerId, newPlayer); characters.Add(obj.id, obj); //Send init data to joined player (map, all players etc) ServerSend.Initialize(_playerId, map.GetMapId(), new List <Player>(players.Values)); //Send player joined event to all players PushEvent(new PlayerJoinedEvent(_playerId, _playerName, _teamId)); }