fix: begin state

This commit is contained in:
Marine 2024-01-28 01:55:35 +01:00
parent a1b5c59197
commit edf23fe41f

View File

@ -4,6 +4,7 @@
using Firebase.Database; using Firebase.Database;
using Firebase.Extensions; using Firebase.Extensions;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using TMPro; using TMPro;
using UnityEngine; using UnityEngine;
using static UnityEditor.Experimental.AssetDatabaseExperimental.AssetDatabaseCounters; using static UnityEditor.Experimental.AssetDatabaseExperimental.AssetDatabaseCounters;
@ -57,6 +58,13 @@ private void Start()
{ {
currentExplanationTime = explanationTime; currentExplanationTime = explanationTime;
HomeConnection.SetActive(true); HomeConnection.SetActive(true);
WaitingRoom.SetActive(false);
BeforeStart.SetActive(false);
TakePicture.SetActive(false);
VotePicture.SetActive(false);
WaitingOtherPlayers.SetActive(false);
EndGame.SetActive(false);
submitNewPlayer.interactable = false; submitNewPlayer.interactable = false;
} }
@ -82,6 +90,7 @@ private void Update()
if (duration.TotalMilliseconds <= 0) if (duration.TotalMilliseconds <= 0)
{ {
Debug.Log("It's time to make proposition !"); Debug.Log("It's time to make proposition !");
endOfExplanationDate = DateTime.MinValue;
} }
} }
} }
@ -288,10 +297,13 @@ public void DisplayEndScreen()
/// </summary> /// </summary>
private void OnRoomUpdate(object sender, ValueChangedEventArgs e) private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
{ {
Debug.Log("begin OnRoomUpdate");
try 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<Room>(e.Snapshot.GetRawJsonValue()); myRoom = JsonConvert.DeserializeObject<Room>(e.Snapshot.GetRawJsonValue());
} }
@ -302,12 +314,15 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
} }
if (myRoom == null) if (myRoom == null)
{ {
Debug.Log("myroom is null");
return; return;
} }
switch (myRoom.currentState) switch (myRoom.currentState)
{ {
case (int)GameState.WaitingForOtherPlayersToJoin: case (int)GameState.WaitingForOtherPlayersToJoin:
{ {
Debug.Log("update player List");
Debug.Log(myRoom.GetPlayerList());
CheckIfIAmTheFirst(myRoom.GetPlayerList()); CheckIfIAmTheFirst(myRoom.GetPlayerList());
UpdateDisplayedListUser(myRoom.GetPlayerList()); UpdateDisplayedListUser(myRoom.GetPlayerList());
break; break;