From edf23fe41fb14ce62c288bea31532f06ab42ff14 Mon Sep 17 00:00:00 2001 From: Marine Date: Sun, 28 Jan 2024 01:55:35 +0100 Subject: [PATCH] fix: begin state --- Assets/Scripts/GameManager.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index cefaed4..6d25655 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -4,6 +4,7 @@ using Firebase.Database; using Firebase.Extensions; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; using TMPro; using UnityEngine; using static UnityEditor.Experimental.AssetDatabaseExperimental.AssetDatabaseCounters; @@ -57,6 +58,13 @@ private void Start() { currentExplanationTime = explanationTime; HomeConnection.SetActive(true); + WaitingRoom.SetActive(false); + BeforeStart.SetActive(false); + TakePicture.SetActive(false); + VotePicture.SetActive(false); + WaitingOtherPlayers.SetActive(false); + EndGame.SetActive(false); + submitNewPlayer.interactable = false; } @@ -82,6 +90,7 @@ private void Update() if (duration.TotalMilliseconds <= 0) { Debug.Log("It's time to make proposition !"); + endOfExplanationDate = DateTime.MinValue; } } } @@ -288,10 +297,13 @@ public void DisplayEndScreen() /// private void OnRoomUpdate(object sender, ValueChangedEventArgs e) { + Debug.Log("begin OnRoomUpdate"); try { - if (e!= null) + if (e?.Snapshot?.GetRawJsonValue() != null) { + string JSON = e.Snapshot.GetRawJsonValue(); + Debug.Log($"your room has been updated :\n{JSON}"); myRoom = JsonConvert.DeserializeObject(e.Snapshot.GetRawJsonValue()); } @@ -302,12 +314,15 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e) } if (myRoom == null) { + Debug.Log("myroom is null"); return; } switch (myRoom.currentState) { case (int)GameState.WaitingForOtherPlayersToJoin: { + Debug.Log("update player List"); + Debug.Log(myRoom.GetPlayerList()); CheckIfIAmTheFirst(myRoom.GetPlayerList()); UpdateDisplayedListUser(myRoom.GetPlayerList()); break;