void OnGUI() { if (isLocalPlayer) { GUILayout.BeginArea(new Rect(0, Screen.height * 0.8f, Screen.width, 100)); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); BP_GameSession gameSession = BP_GameSession.instance; if (gameSession) { if (gameSession.gameState == BP_GameState.Lobby || gameSession.gameState == BP_GameState.Countdown) { if (GUILayout.Button(IsReady() ? "Not Ready" : "Ready", GUILayout.Width(Screen.width * 0.3f), GUILayout.Height(100))) { if (IsReady()) { SendNotReadyToBeginMessage(); } else { SendReadyToBeginMessage(); } } } else if (gameSession.gameState == BP_GameState.WaitForLocationSync) { if (isServer && !locationSent) { gameSession.CmdSendWorldMap(); locationSent = true; } }//Change name of GameState WaitingForRolls Once started BeerPong player logic else if (gameSession.gameState == BP_GameState.WaitingForRolls) { if (GUILayout.Button("Make Sphere", GUILayout.Width(Screen.width * 0.6f), GUILayout.Height(100))) { Transform cameraTransform = _beerPongARSessionManager.CameraTransform(); Vector3 spherePosition = cameraTransform.position + (cameraTransform.forward.normalized * 0.02f); //place sphere 2cm in front of device CmdMakeSphere(spherePosition, cameraTransform.rotation); } } else if (gameSession.gameState == BP_GameState.GameOver) { if (isServer) { if (GUILayout.Button("Play Again", GUILayout.Width(Screen.width * 0.3f), GUILayout.Height(100))) { CmdPlayAgain(); } } } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndArea(); } }
public override void OnJoinedLobby() { networkState = BeerPongNetworkState.Connected; gameSession = FindObjectOfType <BP_GameSession>(); if (gameSession) { gameSession.OnJoinedLobby(); } }
public override void OnServerCreated() { //Create game session BP_GameSession oldSession = FindObjectOfType <BP_GameSession>(); if (oldSession == null) { GameObject serverSession = Instantiate(gameSessionPrefab); NetworkServer.Spawn(serverSession); } else { Debug.LogError("GameSession already exists!"); } }
public override void OnStartClient() { if (instance) { Debug.LogError("ERROR: Another GameSession!"); } instance = this; networkListener = FindObjectOfType <BP_Listener>(); networkListener.gameSession = this; _networkTransmitter = GetComponent <BeerPongNetworkTransmitter>(); if (gameState != BP_GameState.Lobby) { gameState = BP_GameState.Lobby; } }