From fc103f8fab059075741d90c7808f6b65bea24ab6 Mon Sep 17 00:00:00 2001 From: Marine Date: Sun, 28 Jan 2024 02:52:40 +0100 Subject: [PATCH] EndSamePlayer new players --- Assets/Scripts/GameManager.cs | 54 +++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index a291b06..6a5a68c 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -312,14 +312,31 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e) } switch (myRoom.currentState) { + case (int)GameState.EnteringName: + { + if (EndGame.activeInHierarchy) + { + EndGame.SetActive(false); + HomeConnection.SetActive(true); + } + + break; + } case (int)GameState.WaitingForOtherPlayersToJoin: { - CheckIfIAmTheFirst(myRoom.GetPlayerList()); - UpdateDisplayedListUser(myRoom.GetPlayerList()); + if (!HomeConnection.activeInHierarchy) + { + CheckIfIAmTheFirst(myRoom.GetPlayerList()); + UpdateDisplayedListUser(myRoom.GetPlayerList()); + } break; } case (int)GameState.Explanation: { + if (EndGame.activeInHierarchy) + { + EndGame.SetActive(false); + } WaitingRoom.SetActive(false); BeforeStart.SetActive(true); endOfExplanationDate = DateTime.Now.AddSeconds(3); @@ -390,6 +407,39 @@ public void OnClickSubmitSignIn() string roomCode = roomCodeField.text; PlayerValidateNameAndServerRoom(playerName, roomCode); } + + public void onClickSamePlayers() + { + myRoom.currentState = (int)GameState.Explanation; + myRoom.currentQuestion = 2; + myRoom.questions = null; + string json = JsonUtility.ToJson(myRoom); + + myOnlineRoom.SetRawJsonValueAsync(json).ContinueWithOnMainThread(task => + { + if (task.IsFaulted) + { + Debug.LogException(task.Exception); + } + }); + + } + public void onClickNewPlayers() + { + myRoom.currentState = (int)GameState.EnteringName; + myRoom.currentQuestion = 0; + myRoom.questions = null; + myRoom.players = null; + string json = JsonUtility.ToJson(myRoom); + + myOnlineRoom.SetRawJsonValueAsync(json).ContinueWithOnMainThread(task => + { + if (task.IsFaulted) + { + Debug.LogException(task.Exception); + } + }); + } } public enum GameState