mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
Lobby example update (#960)
* Updated Lobby Example * Renamed cube to visor * Missing files from PR 957
This commit is contained in:
parent
e674d4960e
commit
b0b57a23cc
@ -68,7 +68,7 @@ internal void ReadyStatusChanged()
|
||||
if (item != null)
|
||||
{
|
||||
CurrentPlayers++;
|
||||
if (item.ReadyToBegin)
|
||||
if (item.readyToBegin)
|
||||
ReadyPlayers++;
|
||||
}
|
||||
}
|
||||
@ -130,7 +130,7 @@ public void CheckReadyToBegin()
|
||||
{
|
||||
if (SceneManager.GetActiveScene().name != LobbyScene) return;
|
||||
|
||||
if (minPlayers > 0 && NetworkServer.connections.Count(conn => conn.Value != null && conn.Value.playerController.gameObject.GetComponent<NetworkLobbyPlayer>().ReadyToBegin) < minPlayers)
|
||||
if (minPlayers > 0 && NetworkServer.connections.Count(conn => conn.Value != null && conn.Value.playerController.gameObject.GetComponent<NetworkLobbyPlayer>().readyToBegin) < minPlayers)
|
||||
{
|
||||
allPlayersReady = false;
|
||||
return;
|
||||
@ -197,7 +197,7 @@ public override void OnServerDisconnect(NetworkConnection conn)
|
||||
foreach (NetworkLobbyPlayer player in lobbySlots)
|
||||
{
|
||||
if (player != null)
|
||||
player.GetComponent<NetworkLobbyPlayer>().ReadyToBegin = false;
|
||||
player.GetComponent<NetworkLobbyPlayer>().readyToBegin = false;
|
||||
}
|
||||
|
||||
if (SceneManager.GetActiveScene().name == LobbyScene)
|
||||
@ -236,7 +236,7 @@ void RecalculateLobbyPlayerIndices()
|
||||
{
|
||||
for (int i = 0; i < lobbySlots.Count; i++)
|
||||
{
|
||||
lobbySlots[i].Index = i;
|
||||
lobbySlots[i].index = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -258,7 +258,7 @@ public override void ServerChangeScene(string sceneName)
|
||||
if (NetworkServer.active)
|
||||
{
|
||||
// re-add the lobby object
|
||||
lobbyPlayer.GetComponent<NetworkLobbyPlayer>().ReadyToBegin = false;
|
||||
lobbyPlayer.GetComponent<NetworkLobbyPlayer>().readyToBegin = false;
|
||||
NetworkServer.ReplacePlayerForConnection(identity.connectionToClient, lobbyPlayer.gameObject);
|
||||
}
|
||||
}
|
||||
|
@ -8,13 +8,13 @@ namespace Mirror
|
||||
[HelpURL("https://vis2k.github.io/Mirror/Components/NetworkLobbyPlayer")]
|
||||
public class NetworkLobbyPlayer : NetworkBehaviour
|
||||
{
|
||||
public bool ShowLobbyGUI = true;
|
||||
public bool showLobbyGUI = true;
|
||||
|
||||
[SyncVar(hook=nameof(ReadyStateChanged))]
|
||||
public bool ReadyToBegin;
|
||||
public bool readyToBegin;
|
||||
|
||||
[SyncVar]
|
||||
public int Index;
|
||||
public int index;
|
||||
|
||||
#region Unity Callbacks
|
||||
|
||||
@ -34,9 +34,9 @@ public void Start()
|
||||
#region Commands
|
||||
|
||||
[Command]
|
||||
public void CmdChangeReadyState(bool ReadyState)
|
||||
public void CmdChangeReadyState(bool readyState)
|
||||
{
|
||||
ReadyToBegin = ReadyState;
|
||||
readyToBegin = readyState;
|
||||
NetworkLobbyManager lobby = NetworkManager.singleton as NetworkLobbyManager;
|
||||
if (lobby != null)
|
||||
{
|
||||
@ -48,9 +48,9 @@ public void CmdChangeReadyState(bool ReadyState)
|
||||
|
||||
#region SyncVar Hooks
|
||||
|
||||
void ReadyStateChanged(bool NewReadyState)
|
||||
void ReadyStateChanged(bool newReadyState)
|
||||
{
|
||||
OnClientReady(ReadyToBegin);
|
||||
OnClientReady(readyToBegin);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -69,7 +69,7 @@ public virtual void OnClientReady(bool readyState) {}
|
||||
|
||||
public virtual void OnGUI()
|
||||
{
|
||||
if (!ShowLobbyGUI)
|
||||
if (!showLobbyGUI)
|
||||
return;
|
||||
|
||||
NetworkLobbyManager lobby = NetworkManager.singleton as NetworkLobbyManager;
|
||||
@ -81,16 +81,16 @@ public virtual void OnGUI()
|
||||
if (SceneManager.GetActiveScene().name != lobby.LobbyScene)
|
||||
return;
|
||||
|
||||
GUILayout.BeginArea(new Rect(20f + (Index * 100), 200f, 90f, 130f));
|
||||
GUILayout.BeginArea(new Rect(20f + (index * 100), 200f, 90f, 130f));
|
||||
|
||||
GUILayout.Label($"Player [{Index + 1}]");
|
||||
GUILayout.Label($"Player [{index + 1}]");
|
||||
|
||||
if (ReadyToBegin)
|
||||
if (readyToBegin)
|
||||
GUILayout.Label("Ready");
|
||||
else
|
||||
GUILayout.Label("Not Ready");
|
||||
|
||||
if (((isServer && Index > 0) || isServerOnly) && GUILayout.Button("REMOVE"))
|
||||
if (((isServer && index > 0) || isServerOnly) && GUILayout.Button("REMOVE"))
|
||||
{
|
||||
// This button only shows on the Host for all players other than the Host
|
||||
// Host and Players can't remove themselves (stop the client instead)
|
||||
@ -104,7 +104,7 @@ public virtual void OnGUI()
|
||||
{
|
||||
GUILayout.BeginArea(new Rect(20f, 300f, 120f, 20f));
|
||||
|
||||
if (ReadyToBegin)
|
||||
if (readyToBegin)
|
||||
{
|
||||
if (GUILayout.Button("Cancel"))
|
||||
CmdChangeReadyState(false);
|
||||
|
Loading…
Reference in New Issue
Block a user