From 723edde6476f130f27035bb78923e72a7abc5d96 Mon Sep 17 00:00:00 2001 From: Fangh Date: Sun, 4 Feb 2024 12:04:24 +0100 Subject: [PATCH] WIP restart same players --- Assets/Scripts/CameraManager.cs | 1 + Assets/Scripts/GameManager.cs | 22 ++++++++-------------- Assets/Scripts/RoomManager.cs | 5 +---- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/Assets/Scripts/CameraManager.cs b/Assets/Scripts/CameraManager.cs index e1efc06..982d41f 100644 --- a/Assets/Scripts/CameraManager.cs +++ b/Assets/Scripts/CameraManager.cs @@ -49,6 +49,7 @@ public void WebcamResume() wTexture.Play(); photo = null; + photoBox.texture = null; freezeButton.gameObject.SetActive(true); resumeButton.gameObject.SetActive(false); } diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 0fdfada..766390b 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -341,20 +341,13 @@ private void OnNewGameState() { case (int)GameState.EnteringName: { - if (EndGame.activeInHierarchy) - { - EndGame.SetActive(false); - HomeConnection.SetActive(true); - } - + EndGame.SetActive(false); + HomeConnection.SetActive(true); break; } case (int)GameState.Explanation: { - if (EndGame.activeInHierarchy) - { - EndGame.SetActive(false); - } + EndGame.SetActive(false); WaitingRoom.SetActive(false); BeforeStart.SetActive(true); endOfViewDate = DateTime.Now.AddSeconds(4); @@ -473,10 +466,11 @@ public void OnClickSubmitSignIn() public void onClickSamePlayers() { - myRoom.currentState = (int)GameState.Explanation; - myRoom.questions = null; - myRoom.currentQuestionId = 0; - string json = JsonConvert.SerializeObject(myRoom); + Room newRoom = myRoom; + newRoom.currentState = (int)GameState.Explanation; + newRoom.questions.Clear(); + newRoom.currentQuestionId = 0; + string json = JsonConvert.SerializeObject(newRoom); myOnlineRoom.SetRawJsonValueAsync(json).ContinueWithOnMainThread(task => { diff --git a/Assets/Scripts/RoomManager.cs b/Assets/Scripts/RoomManager.cs index 11f476a..74c8e64 100644 --- a/Assets/Scripts/RoomManager.cs +++ b/Assets/Scripts/RoomManager.cs @@ -6,12 +6,9 @@ using UnityEngine; using Newtonsoft.Json; using System.Linq; -using Google.MiniJSON; using Firebase.Storage; -using System.Security.Policy; using System.Threading.Tasks; using System.Collections; -using System.Security.Cryptography; public class RoomManager : MonoBehaviour { @@ -138,7 +135,6 @@ private void Initialize() /// /// Check all the rooms in the server and give back the number already taken /// - private void WhichCodesAreAlreadyUsed(Action> callback_OnCodesChecked) { QueryRoomsInDatabase(onlineRooms => @@ -288,6 +284,7 @@ private void OnNewGameStateStarted() case (int)GameState.Explanation: Debug.Log("New State : Explanation"); + scoringPage.gameObject.SetActive(false); //if we come back from a new game waitingForPlayersPage.SetActive(false); explanationPage.SetActive(true); endOfExplanationDate = DateTime.Now.AddSeconds(explanationTime);