void OnGUI() { if (isLocalPlayer) { GUILayout.BeginArea(new Rect(0, Screen.height * 0.8f, Screen.width, 100)); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); ExampleGameSession gameSession = ExampleGameSession.instance; if (gameSession) { if (gameSession.gameState == GameState.Lobby || gameSession.gameState == GameState.Countdown) { if (GUILayout.Button(IsReady() ? "Not ready" : "Ready", GUILayout.Width(Screen.width * 0.3f), GUILayout.Height(100))) { if (IsReady()) { SendNotReadyToBeginMessage(); } else { SendReadyToBeginMessage(); } } } } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.EndArea(); } }
public override void OnJoinedLobby() { networkState = NetworkState.Connected; gameSession = FindObjectOfType<ExampleGameSession>(); if (gameSession) { gameSession.OnJoinedLobby(); } }
public override void OnJoinedLobby() { networkState = NetworkState.Connected; gameSession = FindObjectOfType <ExampleGameSession>(); if (gameSession) { gameSession.OnJoinedLobby(); } }
void OnGUI() { if (isLocalPlayer) { GUILayout.BeginArea(new Rect(0, Screen.height * 0.8f, Screen.width, 100)); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); ExampleGameSession gameSession = ExampleGameSession.instance; if (gameSession) { if (gameSession.gameState == GameState.Lobby || gameSession.gameState == 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 == GameState.WaitingForRolls) { if (rollResult == 0) { if (GUILayout.Button("Roll Die", GUILayout.Width(Screen.width * 0.3f), GUILayout.Height(100))) { CmdRollDie(); } } } else if (gameSession.gameState == 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 OnStartClient() { if (instance) { Debug.LogError("ERROR: Another GameSession!"); } instance = this; networkListener = FindObjectOfType<ExampleListener>(); networkListener.gameSession = this; if (gameState != GameState.Lobby) { gameState = GameState.Lobby; } }
public override void OnServerCreated() { // Create game session ExampleGameSession oldSession = FindObjectOfType <ExampleGameSession>(); 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 <ExampleListener>(); networkListener.gameSession = this; if (gameState != GameState.Lobby) { gameState = GameState.Lobby; } }
public void Update() { string synced = locationSynced ? "SYNC" : "NO"; totalPointsField.text = "Points: " + totalPoints.ToString() + synced; if (rollResult > 0) { rollResultField.text = "Roll: " + rollResult.ToString(); } else { rollResultField.text = ""; } if (Input.touchCount < 1) { return; } //the instantiation current curve logic ExampleGameSession gameSession = ExampleGameSession.instance; if (isLocalPlayer && gameSession && gameSession.gameState == GameState.WaitingForRolls) { Touch touch = Input.GetTouch(0); if (canStartDraw && touch.phase == TouchPhase.Began) { Debug.Log("ENTERED instantiation"); Ray raycast = Camera.main.ScreenPointToRay(Input.mousePosition); Vector3 point = raycast.GetPoint(2); canStartDraw = false; //instantiate bezier across all clients CmdMakeSphere(point); } else if (touch.phase == TouchPhase.Ended || touch.phase == TouchPhase.Canceled) { //if the user right click, then finished this bezier Debug.Log("stop draw"); currentBezier.GetComponent <BezierMaster.BezierMaster>().stop = true; currentBezier = null; canStartDraw = true; } } }
void OnGUI() { if (isLocalPlayer) { GUILayout.BeginArea(new Rect(0, Screen.height * 0.8f, Screen.width, 100)); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); ExampleGameSession gameSession = ExampleGameSession.instance; if (gameSession) { if (gameSession.gameState == GameState.Lobby || gameSession.gameState == 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 == GameState.WaitForLocationSync) { if (isServer && !locationSent) { gameSession.CmdSendWorldMap(); locationSent = true; } } else if (gameSession.gameState == GameState.WaitingForRolls) { // if (rollResult == 0) // { // if (GUILayout.Button("Roll Die", GUILayout.Width(Screen.width * 0.3f), GUILayout.Height(100))) // { // CmdRollDie(); // } // } { if (GUILayout.Button("Make Sphere", GUILayout.Width(Screen.width * 0.6f), GUILayout.Height(100))) { Transform camTransform = _exampleARSessionManager.CameraTransform(); Vector3 spherePosition = camTransform.position + (camTransform.forward.normalized * 0.02f); //place sphere 2cm in front of device CmdMakeSphere(spherePosition, camTransform.rotation); } } } else if (gameSession.gameState == 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(); } }