public void OnFNLobbyMasterKnowledgeTransfer(ILobbyMaster previousLobbyMaster) { LobbyPlayers.Clear(); LobbyPlayersMap.Clear(); LobbyTeams.Clear(); for (int i = 0; i < previousLobbyMaster.LobbyPlayers.Count; ++i) { IClientMockPlayer player = previousLobbyMaster.LobbyPlayers[i]; LobbyPlayers.Add(player); LobbyPlayersMap.Add(player.NetworkId, player); } IEnumerator iter = previousLobbyMaster.LobbyTeams.GetEnumerator(); iter.Reset(); while (iter.MoveNext()) { if (iter.Current != null) { KeyValuePair <int, List <IClientMockPlayer> > kv = (KeyValuePair <int, List <IClientMockPlayer> >)iter.Current; LobbyTeams.Add(kv.Key, kv.Value); } else { break; } } foreach (KeyValuePair <int, List <IClientMockPlayer> > kv in previousLobbyMaster.LobbyTeams) { LobbyTeams.Add(kv.Key, kv.Value); } }
private void SetupComplete() { LobbyService.Instance.SetLobbyMaster(this); LobbyService.Instance.Initialize(NetworkManager.Instance.Networker); //If I am the host, then I should show the kick button for all players here LobbyPlayerItem item = GetNewPlayerItem(); //This will just auto generate the 10 items we need to start with item.SetParent(Grid); PutBackToPool(item); _myself = GrabPlayer(LobbyService.Instance.MyMockPlayer); if (!LobbyPlayers.Contains(_myself)) { LobbyPlayers.Add(_myself); } Myself.Init(this); Myself.Setup(_myself, true); List <IClientMockPlayer> currentPlayers = LobbyService.Instance.MasterLobby.LobbyPlayers; for (int i = 0; i < currentPlayers.Count; ++i) { IClientMockPlayer currentPlayer = currentPlayers[i]; if (currentPlayer == _myself) { continue; } OnFNPlayerConnected(currentPlayers[i]); } }
public void OnFNPlayerDisconnected(IClientMockPlayer player) { if (LobbyPlayers.Contains(player)) { LobbyPlayers.Remove(player); LobbyPlayersMap.Remove(player.NetworkId); } }
public void OnFNPlayerConnected(IClientMockPlayer player) { if (!LobbyPlayers.Contains(player)) { LobbyPlayers.Add(player); LobbyPlayersMap.Add(player.NetworkId, player); } }
public void OnFNLobbyMasterKnowledgeTransfer(ILobbyMaster previousLobbyMaster) { LobbyPlayers.Clear(); LobbyPlayersMap.Clear(); LobbyTeams.Clear(); for (int i = 0; i < previousLobbyMaster.LobbyPlayers.Count; ++i) { LobbyPlayer player = GrabPlayer(previousLobbyMaster.LobbyPlayers[i]); LobbyPlayers.Add(player); LobbyPlayersMap.Add(player.NetworkId, player); } IEnumerator iterTeams = previousLobbyMaster.LobbyTeams.GetEnumerator(); iterTeams.Reset(); while (iterTeams.MoveNext()) { if (iterTeams.Current != null) { KeyValuePair <int, List <IClientMockPlayer> > kv = (KeyValuePair <int, List <IClientMockPlayer> >)iterTeams.Current; List <IClientMockPlayer> players = new List <IClientMockPlayer>(); for (int i = 0; i < kv.Value.Count; ++i) { players.Add(GrabPlayer(kv.Value[i])); } LobbyTeams.Add(kv.Key, players); } else { break; } } IEnumerator iterPlayersMap = previousLobbyMaster.LobbyPlayersMap.GetEnumerator(); iterPlayersMap.Reset(); while (iterPlayersMap.MoveNext()) { if (iterPlayersMap.Current != null) { KeyValuePair <uint, IClientMockPlayer> kv = (KeyValuePair <uint, IClientMockPlayer>)iterPlayersMap.Current; if (LobbyPlayersMap.ContainsKey(kv.Key)) { LobbyPlayersMap[kv.Key] = GrabPlayer(kv.Value); } else { LobbyPlayersMap.Add(kv.Key, GrabPlayer(kv.Value)); } } else { break; } } }
private void OnServerDisconnectLobby(NetworkConnection conn) { if (conn.identity != null) { LobbyPlayer player = conn.identity.GetComponent <LobbyPlayer>(); LobbyPlayers.Remove(player); NotifyLobbyOfReadyState(); } }
public DummyLobbyMaster() { DummyPlayer player = new DummyPlayer(0, "Server", 0, 0); LobbyPlayers.Add(player); LobbyPlayersMap.Add(0, player); LobbyTeams.Add(0, new List <IClientMockPlayer>() { player }); }
public override void OnServerDisconnect(NetworkConnection conn) { if (conn.identity != null) { var player = conn.identity.GetComponent <NetworkLobbyPlayer>(); LobbyPlayers.Remove(player); NotifyPlayersOfReadyState(); } base.OnServerDisconnect(conn); }
public void OnFNPlayerConnected(IClientMockPlayer player) { LobbyPlayer convertedPlayer = GrabPlayer(player); if (convertedPlayer == _myself || _myself == null) { return; //Ignore re-adding ourselves } bool playerCreated = false; for (int i = 0; i < _lobbyPlayersPool.Count; ++i) { if (_lobbyPlayersPool[i].AssociatedPlayer.NetworkId == player.NetworkId) { playerCreated = true; } } playerCreated = convertedPlayer.Created; if (playerCreated) { return; } convertedPlayer.Created = true; if (!LobbyPlayers.Contains(convertedPlayer)) { _lobbyPlayers.Add(convertedPlayer); } if (_lobbyPlayersMap.ContainsKey(convertedPlayer.NetworkId)) { _lobbyPlayersMap[convertedPlayer.NetworkId] = convertedPlayer; } else { _lobbyPlayersMap.Add(convertedPlayer.NetworkId, convertedPlayer); } OnFNTeamChanged(convertedPlayer); MainThreadManager.Run(() => { LobbyPlayerItem item = GetNewPlayerItem(); item.Setup(convertedPlayer, false); if (LobbyService.Instance.IsServer) { item.KickButton.SetActive(true); } item.SetParent(Grid); }); }
public override void OnServerDisconnect(NetworkConnection conn) { if (conn.identity != null) { var _player = conn.identity.GetComponent <NetworkPlayerLobby>(); LobbyPlayers.Remove(_player); CheckReadyStates(); } base.OnServerDisconnect(conn); }
public void OnFNPlayerDisconnected(IClientMockPlayer player) { LobbyPlayer convertedPlayer = GrabPlayer(player); MainThreadManager.Run(() => { if (LobbyPlayers.Contains(convertedPlayer)) { _lobbyPlayers.Remove(convertedPlayer); _lobbyPlayersMap.Remove(convertedPlayer.NetworkId); LobbyPlayerItem item = GrabLobbyPlayerItem(convertedPlayer); if (item != null) { PutBackToPool(item); } } }); }
private Task PlayerJoinedLobby(string playerObject, int currentLobby) { if (debug) { Console.WriteLine($"OBSERVER: NetworkManagerClient PlayerJoinedLobby"); } Player player = JsonConvert.DeserializeObject <Player>(playerObject); Console.WriteLine(player.ConnectionId + " " + Me.ConnectionId); LobbyPlayers.Add(player); if (player.ConnectionId == Me.ConnectionId) { CurrentLobby = currentLobby; SceneManager.Instance.LoadScene <IngobbyScene>(); } else { Console.WriteLine(player.Name + " has joined your lobby!"); } return(Task.CompletedTask); }
public override void OnStopServer() { LobbyPlayers.Clear(); }