private List <LidgrenIdentifiedPlayer> AddNewPlayersOnServer() { var newPlayers = new List <LidgrenIdentifiedPlayer>(); int numberOfPlayers = _incomingMessage.ReadVariableInt32(); for (int i = 0; i < numberOfPlayers; i++) { // we retrieve the player sent by the client var player = new LidgrenIdentifiedPlayer(_incomingMessage.ReadString()) { DisplayName = _incomingMessage.ReadString(), }; _remotePlayerIpEndPoints.Add(player, _incomingMessage.SenderEndPoint); // we test if the provided player is local var localPlayer = LidgrenSessionManager.LocalPlayers.Values.FirstOrDefault(p => p == player); if (localPlayer != null) { _allPlayers.Add(localPlayer); } else { _allPlayers.Add(player); newPlayers.Add(player); } } LidgrenSessionManager.Server.Connections.Add(new NetConnection(new NetPeer(new NetPeerConfiguration("scrap")), _incomingMessage.SenderEndPoint)); return(newPlayers); }
private void RetrieveRemotePlayersFromServer() { int remotePlayers = _incomingMessage.ReadVariableInt32(); for (int i = 0; i < remotePlayers; i++) { var uniqueId = _incomingMessage.ReadString(); var displayName = _incomingMessage.ReadString(); var isHost = _incomingMessage.ReadBoolean(); var isOnServer = _incomingMessage.ReadBoolean(); var player = new LidgrenIdentifiedPlayer(uniqueId) { DisplayName = displayName, }; if (isHost) { player.SetIsHost(); } _remotePlayers.Add(player); _allPlayers.Add(player); if (isOnServer) { _remotePlayerIpEndPoints.Add(player, LidgrenSessionManager.Client.ServerConnection.RemoteEndpoint); } else { _remotePlayerIpEndPoints.Add(player, _incomingMessage.ReadIPEndpoint()); } OnPlayerJoined(player); } }
private List <LidgrenIdentifiedPlayer> AddNewPlayersOnServer() { var newPlayers = new List <LidgrenIdentifiedPlayer>(); int numberOfPlayers = _incomingMessage.ReadVariableInt32(); for (int i = 0; i < numberOfPlayers; i++) { // we retrieve the player sent by the client var player = new LidgrenIdentifiedPlayer(_incomingMessage.ReadString()) { DisplayName = _incomingMessage.ReadString(), }; // we test if the provided player is local foreach (var localPlayer in LidgrenSessionManager.LocalPlayers.Values) { // if that is the case, we add the local player to the server session in AllPlayers list. if (localPlayer == player) { _allPlayers.Add(localPlayer); } // otherwise, we add the remote player to the server session in AllPlayers list. else { _allPlayers.Add(player); } newPlayers.Add(player); } } return(newPlayers); }
/// <summary> /// Identifies a player /// </summary> /// <param name="playerInput">The PlayerInput instance used by the player to identify</param> public override void IdentifyPlayer(PlayerInput playerInput) { var identifiedPlayer = new LidgrenIdentifiedPlayer(playerInput); LocalPlayers.Add(playerInput.PlayerIndex, identifiedPlayer); OnPlayerLogin(identifiedPlayer); }
private void RetrieveNewPlayersFromServer() { int numberOfNewPlayers = _incomingMessage.ReadVariableInt32(); IPEndPoint ipEndPoint = _incomingMessage.ReadIPEndpoint(); for (int i = 0; i < numberOfNewPlayers; i++) { var player = new LidgrenIdentifiedPlayer(_incomingMessage.ReadString()) { DisplayName = _incomingMessage.ReadString(), }; _remotePlayers.Add(player); _remotePlayerIpEndPoints.Add(player, ipEndPoint); _allPlayers.Add(player); OnPlayerJoined(player); } }
private void RetrieveNewPlayersFromServer() { int numberOfNewPlayers = _incomingMessage.ReadVariableInt32(); IPEndPoint ipEndPoint = _incomingMessage.ReadIPEndPoint(); for (int i = 0; i < numberOfNewPlayers; i++) { var player = new LidgrenIdentifiedPlayer(_incomingMessage.ReadString()) { DisplayName = _incomingMessage.ReadString(), }; _remotePlayers.Add(player); if (!LidgrenSessionManager.CurrentSession.IsHost) { _remotePlayerIpEndPoints.Add(player, ipEndPoint); _allPlayers.Add(player); } OnPlayerJoined(player); } }
private void RetrieveRemotePlayersFromServer() { int remotePlayers = _incomingMessage.ReadVariableInt32(); for (int i = 0; i < remotePlayers; i++) { var uniqueId = _incomingMessage.ReadString(); var displayName = _incomingMessage.ReadString(); var isHost = _incomingMessage.ReadBoolean(); var isOnServer = _incomingMessage.ReadBoolean(); var player = new LidgrenIdentifiedPlayer(uniqueId) { DisplayName = displayName, }; if (isHost) player.SetIsHost(); if (!LidgrenSessionManager.CurrentSession.IsHost) { _remotePlayers.Add(player); _allPlayers.Add(player); if (isOnServer) _remotePlayerIpEndPoints.Add(player, LidgrenSessionManager.Client.ServerConnection.RemoteEndPoint); else _remotePlayerIpEndPoints.Add(player, _incomingMessage.ReadIPEndPoint()); } OnPlayerJoined(player); } }
private List<LidgrenIdentifiedPlayer> AddNewPlayersOnServer() { var newPlayers = new List<LidgrenIdentifiedPlayer>(); int numberOfPlayers = _incomingMessage.ReadVariableInt32(); for (int i = 0; i < numberOfPlayers; i++) { // we retrieve the player sent by the client var player = new LidgrenIdentifiedPlayer(_incomingMessage.ReadString()) { DisplayName = _incomingMessage.ReadString(), }; // we test if the provided player is local foreach ( var localPlayer in LidgrenSessionManager.LocalPlayers.Values) { // if that is the case, we add the local player to the server session in AllPlayers list. if (localPlayer == player) { _allPlayers.Add(localPlayer); } // otherwise, we add the remote player to the server session in AllPlayers list. else { _allPlayers.Add(player); } newPlayers.Add(player); } } return newPlayers; }
private List<LidgrenIdentifiedPlayer> AddNewPlayersOnServer() { var newPlayers = new List<LidgrenIdentifiedPlayer>(); int numberOfPlayers = _incomingMessage.ReadVariableInt32(); for (int i = 0; i < numberOfPlayers; i++) { // we retrieve the player sent by the client var player = new LidgrenIdentifiedPlayer(_incomingMessage.ReadString()) { DisplayName = _incomingMessage.ReadString(), }; _remotePlayerIpEndPoints.Add(player, _incomingMessage.SenderEndPoint); // we test if the provided player is local var localPlayer = LidgrenSessionManager.LocalPlayers.Values.FirstOrDefault(p => p == player); if (localPlayer != null) { _allPlayers.Add(localPlayer); } else { _allPlayers.Add(player); newPlayers.Add(player); } } LidgrenSessionManager.Server.Connections.Add(new NetConnection(new NetPeer(new NetPeerConfiguration("scrap")), _incomingMessage.SenderEndPoint)); return newPlayers; }