From 1a724ac03c4f9cbcd9ebacf876f6a5c97e095e7f Mon Sep 17 00:00:00 2001 From: Fangh Date: Sun, 28 Jan 2024 16:34:06 +0100 Subject: [PATCH 1/3] fix: manage when no propositions --- Assets/Scripts/VotingPage.cs | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/Assets/Scripts/VotingPage.cs b/Assets/Scripts/VotingPage.cs index 78b762d..6ec4eea 100644 --- a/Assets/Scripts/VotingPage.cs +++ b/Assets/Scripts/VotingPage.cs @@ -38,7 +38,11 @@ private void Update() return; - if (endOfTimer <= DateTime.Now) + if (DateTime.Now < endOfTimer) + { + timerLabel.text = (DateTime.Now - endOfTimer).TotalSeconds.ToString("D2"); + } + else { timerLabel.text = "0"; if (remainingQuestions.Count > 0) @@ -51,10 +55,6 @@ private void Update() OnVoteEnded?.Invoke(); } } - else - { - timerLabel.text = (DateTime.Now - endOfTimer).ToString("D2"); - } } @@ -130,19 +130,24 @@ private void OnQuestionChanged(object sender, ValueChangedEventArgs _questionRef private void UpdateVoters() { - List playersThatHasVotedForFirstProposition = new List(); - foreach (string playerId in currentQuestion.propositions[0].voters) + if (currentQuestion.propositions[0] != null) { - playersThatHasVotedForFirstProposition.Add(currentPlayers[playerId]); + List playersThatHasVotedForFirstProposition = new List(); + foreach (string playerId in currentQuestion.propositions[0].voters) + { + playersThatHasVotedForFirstProposition.Add(currentPlayers[playerId]); + } + proposition1.UpdateVoters(playersThatHasVotedForFirstProposition); } - List playersThatHasVotedForSecondProposition = new List(); - foreach (string playerId in currentQuestion.propositions[1].voters) + if (currentQuestion.propositions[1] != null) { - playersThatHasVotedForSecondProposition.Add(currentPlayers[playerId]); + List playersThatHasVotedForSecondProposition = new List(); + foreach (string playerId in currentQuestion.propositions[1].voters) + { + playersThatHasVotedForSecondProposition.Add(currentPlayers[playerId]); + } + proposition2.UpdateVoters(playersThatHasVotedForSecondProposition); } - - proposition1.UpdateVoters(playersThatHasVotedForFirstProposition); - proposition2.UpdateVoters(playersThatHasVotedForSecondProposition); } } From 33d8281e04ade1a22d512e2781dfeb4bdd30694b Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Sun, 28 Jan 2024 16:36:37 +0100 Subject: [PATCH 2/3] fix: cameramanager --- Assets/Scenes/PhoneView.unity | 5 +++-- Assets/Scripts/StorageManager.cs | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Assets/Scenes/PhoneView.unity b/Assets/Scenes/PhoneView.unity index ab86e18..54090d1 100644 --- a/Assets/Scenes/PhoneView.unity +++ b/Assets/Scenes/PhoneView.unity @@ -316,8 +316,8 @@ MonoBehaviour: propositionCounter: {fileID: 0} propositionTime: 60 waitingForPropositionsLabels: [] + votingPage: {fileID: 0} promptList: {fileID: 0} - votingTime: 20 --- !u!4 &157909815 Transform: m_ObjectHideFlags: 0 @@ -987,6 +987,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 3b41deef4ebd372d5a18eabdb00cfbb4, type: 3} m_Name: m_EditorClassIdentifier: + cameraManager: {fileID: 1181392807} --- !u!114 &429358653 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1022,7 +1023,7 @@ MonoBehaviour: EndGame: {fileID: 1850164816} myRoom: code: - currentQuestion: 0 + currentQuestionId: creationDate: 0 currentState: 0 --- !u!1 &436596783 diff --git a/Assets/Scripts/StorageManager.cs b/Assets/Scripts/StorageManager.cs index f5705a7..9c46b4a 100644 --- a/Assets/Scripts/StorageManager.cs +++ b/Assets/Scripts/StorageManager.cs @@ -6,7 +6,7 @@ public class StorageManager : MonoBehaviour { - public GameObject managers; + public CameraManager cameraManager; private StorageReference storage; private DatabaseReference realtimeDB; @@ -36,10 +36,10 @@ void Update() public void UploadPhoto(string roomCode, string playerId, int question, int proposition) { - Texture2D photo = managers.GetComponent().GetPhoto(); + Texture2D photo = cameraManager.GetPhoto(); byte[] photoBytes = ImageConversion.EncodeToJPG(photo); - GameManager game = managers.GetComponent(); + GameManager game = gameObject.GetComponent(); string imageUuid = Guid.NewGuid().ToString(); StorageReference imageRef = storage.Child($"{roomCode}/{playerId}/{imageUuid}.png"); From fa70ac72880716d6e3d57ab10bd452c08eac74a3 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Sun, 28 Jan 2024 16:39:05 +0100 Subject: [PATCH 3/3] gameManager not usefull --- Assets/Scripts/StorageManager.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/Assets/Scripts/StorageManager.cs b/Assets/Scripts/StorageManager.cs index 9c46b4a..1c2632d 100644 --- a/Assets/Scripts/StorageManager.cs +++ b/Assets/Scripts/StorageManager.cs @@ -38,8 +38,6 @@ public void UploadPhoto(string roomCode, string playerId, int question, int prop { Texture2D photo = cameraManager.GetPhoto(); byte[] photoBytes = ImageConversion.EncodeToJPG(photo); - - GameManager game = gameObject.GetComponent(); string imageUuid = Guid.NewGuid().ToString(); StorageReference imageRef = storage.Child($"{roomCode}/{playerId}/{imageUuid}.png");