/*
* Renders the lobby room and player create menu
*/
void OnGUI()
{
// lobby
if (gameState == GameState.InLobby)
{
GUILayout.BeginArea(new Rect(Screen.width / 2 - 150, Screen.height / 2 - 150, 300, 300));
playerName = GUILayout.TextField(playerName);
roomName = GUILayout.TextField(roomName);
if (GUILayout.Button("Create"))
{
PhotonNetwork.JoinOrCreateRoom(roomName, null, null);
}
// Display a list of available rooms on the server
foreach (RoomInfo game in PhotonNetwork.GetRoomList())
{
if (GUILayout.Button(game.name + " " + game.playerCount + "/" + game.maxPlayers))
{
PhotonNetwork.JoinOrCreateRoom(game.name, null, null);
}
}
GUILayout.EndArea();
}
// room
if (gameState == GameState.InRoom)
{
GUILayout.BeginArea(new Rect(Screen.width / 2 - 150, Screen.height / 2 - 150, 300, 300));
GUILayout.Box("Your current score: " + PhotonNetwork.player.GetScore());
// Class selection
GUILayout.Label("Choose your class");
if (GUILayout.Button("SWAT"))
{
spawnPlayer(SWAT);
}
if (GUILayout.Button("Assault"))
{
spawnPlayer(Assault);
}
GUILayout.Label("");
if (GUILayout.Button("Quit room"))
{
PhotonNetwork.Disconnect();
SceneManager.LoadScene(0);
}
GUILayout.EndArea();
}
if (gameState == GameState.Die)
{
GUILayout.BeginArea(new Rect(Screen.width / 2 - 150, Screen.height / 2 - 150, 300, 300));
GUILayout.Box("You Died");
if (GUILayout.Button("Back to room"))
{
PhotonNetwork.Destroy(ragDoll);
OnJoinedRoom();
}
GUILayout.EndArea();
}
}