public override void OnLobbyServerPlayerRemoved(NetworkConnection conn, short playerControllerId) { for (int i = 0; i < lobbySlots.Length; ++i) { LobbyPlayer p = lobbySlots[i] as LobbyPlayer; if (p != null) { p.RpcUpdateRemoveButton(); p.ToggleJoinButton(numPlayers + 1 >= minPlayers); } } }
public override void OnLobbyServerDisconnect(NetworkConnection conn) { for (int i = 0; i < lobbySlots.Length; ++i) { LobbyPlayer p = lobbySlots[i] as LobbyPlayer; if (p != null) { p.RpcUpdateRemoveButton(); p.ToggleJoinButton(numPlayers >= minPlayers); } } }
public override void OnLobbyServerDisconnect(NetworkConnection conn) { //Debug.Log("A client disconnect "+disconnectedClientId); //todo: tell all client that one of them has been disconnect. for (int i = 0; i < lobbySlots.Length; ++i) { LobbyPlayer p = lobbySlots[i] as LobbyPlayer; if (p != null) { p.RpcUpdateRemoveButton(); p.ToggleJoinButton(numPlayers >= minPlayers); } } Invoke("ReassignClientId", 0.2f); }
// ----------------- Server callbacks ------------------ //we want to disable the button JOIN if we don't have enough player //But OnLobbyClientConnect isn't called on hosting player. So we override the lobbyPlayer creation public override GameObject OnLobbyServerCreateLobbyPlayer(NetworkConnection conn, short playerControllerId) { GameObject obj = Instantiate(lobbyPlayerPrefab.gameObject) as GameObject; LobbyPlayer newPlayer = obj.GetComponent <LobbyPlayer>(); newPlayer.ToggleJoinButton(numPlayers + 1 >= minPlayers); for (int i = 0; i < lobbySlots.Length; ++i) { LobbyPlayer p = lobbySlots[i] as LobbyPlayer; if (p != null) { p.RpcUpdateRemoveButton(); p.ToggleJoinButton(numPlayers + 1 >= minPlayers); } } return(obj); }