From 764a39d053b16782cb9bf4b57b9ea825d3ae645f Mon Sep 17 00:00:00 2001 From: Fangh Date: Sun, 4 Feb 2024 13:32:08 +0100 Subject: [PATCH] fix: correct pages should toggle at correct time --- Assets/Scripts/GameManager.cs | 68 +++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 27 deletions(-) diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 98be0df..fa48f50 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -340,56 +340,70 @@ private void OnNewGameState() { case (int)GameState.EnteringName: { + WaitingOtherPlayers.SetActive(false); + BeforeStart.SetActive(false); + TakePicture.SetActive(false); + VotePicture.SetActive(false); EndGame.SetActive(false); + HomeConnection.SetActive(true); break; } case (int)GameState.Explanation: { Debug.Log("Explanation time.", this); - EndGame.SetActive(false); + WaitingOtherPlayers.SetActive(false); + TakePicture.SetActive(false); WaitingRoom.SetActive(false); + VotePicture.SetActive(false); + EndGame.SetActive(false); + BeforeStart.SetActive(true); endOfViewDate = DateTime.Now.AddSeconds(4); break; } case (int)GameState.MakeProposition: { - if (BeforeStart.activeInHierarchy) - { - Debug.Log("It's photo time !", this); - BeforeStart.SetActive(false); - TakePicture.SetActive(true); - endOfViewDate = DateTime.Now.AddSeconds(60); - } + Debug.Log("It's photo time !", this); + WaitingOtherPlayers.SetActive(false); + BeforeStart.SetActive(false); + WaitingRoom.SetActive(false); + VotePicture.SetActive(false); + EndGame.SetActive(false); + + TakePicture.SetActive(true); + endOfViewDate = DateTime.Now.AddSeconds(60); break; } case (int)GameState.MakeVote: { - if (TakePicture.activeInHierarchy || WaitingOtherPlayers.activeInHierarchy) - { - Debug.Log("It's voting time !", this); - WaitingOtherPlayers.SetActive(false); - TakePicture.SetActive(false); - VotePicture.SetActive(true); - myOnlineRoom.Child("currentQuestionId").ValueChanged += OnCurrentQuestionChanged; - } + Debug.Log("It's voting time !", this); + WaitingOtherPlayers.SetActive(false); + BeforeStart.SetActive(false); + WaitingRoom.SetActive(false); + TakePicture.SetActive(false); + EndGame.SetActive(false); + + VotePicture.SetActive(true); + myOnlineRoom.Child("currentQuestionId").ValueChanged += OnCurrentQuestionChanged; break; } case (int)GameState.Score: { - if (VotePicture.activeInHierarchy || WaitingOtherPlayers.activeInHierarchy) - { - Debug.Log("it's scoring time !", this); - myOnlineRoom.Child("currentQuestionId").ValueChanged -= OnCurrentQuestionChanged; + Debug.Log("it's scoring time !", this); + myOnlineRoom.Child("currentQuestionId").ValueChanged -= OnCurrentQuestionChanged; - VotePicture.SetActive(false); - WaitingOtherPlayers.SetActive(false); - endGameFirstPlayer.SetActive(CheckIfIAmTheFirst(myRoom.GetPlayerList())); - endGameOtherPlayers.SetActive(!CheckIfIAmTheFirst(myRoom.GetPlayerList())); - EndGame.SetActive(true); - } + WaitingOtherPlayers.SetActive(false); + BeforeStart.SetActive(false); + WaitingRoom.SetActive(false); + TakePicture.SetActive(false); + VotePicture.SetActive(false); + + EndGame.SetActive(true); + + endGameFirstPlayer.SetActive(CheckIfIAmTheFirst(myRoom.GetPlayerList())); + endGameOtherPlayers.SetActive(!CheckIfIAmTheFirst(myRoom.GetPlayerList())); break; } @@ -514,7 +528,7 @@ private void OnCurrentQuestionChanged(object sender, ValueChangedEventArgs onlin Question q = myRoom.questions[questionId]; //do not vote for your question - if(myRoom.GetQuestionsByPlayer(currentPlayer).Contains(q)) + if (myRoom.GetQuestionsByPlayer(currentPlayer).Contains(q)) { WaitingOtherPlayers.SetActive(true); VotePicture.SetActive(false);