Merge branch 'main' of ssh://patema.crystalyx.net:2222/GameJams/Snaparazzi

This commit is contained in:
Marine 2024-01-28 16:43:06 +01:00
commit d36dad28bd
3 changed files with 24 additions and 20 deletions

View File

@ -316,8 +316,8 @@ MonoBehaviour:
propositionCounter: {fileID: 0} propositionCounter: {fileID: 0}
propositionTime: 60 propositionTime: 60
waitingForPropositionsLabels: [] waitingForPropositionsLabels: []
votingPage: {fileID: 0}
promptList: {fileID: 0} promptList: {fileID: 0}
votingTime: 20
--- !u!4 &157909815 --- !u!4 &157909815
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -987,6 +987,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 3b41deef4ebd372d5a18eabdb00cfbb4, type: 3} m_Script: {fileID: 11500000, guid: 3b41deef4ebd372d5a18eabdb00cfbb4, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
cameraManager: {fileID: 1181392807}
--- !u!114 &429358653 --- !u!114 &429358653
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -1022,7 +1023,7 @@ MonoBehaviour:
EndGame: {fileID: 1850164816} EndGame: {fileID: 1850164816}
myRoom: myRoom:
code: code:
currentQuestion: 0 currentQuestionId:
creationDate: 0 creationDate: 0
currentState: 0 currentState: 0
--- !u!1 &436596783 --- !u!1 &436596783

View File

@ -6,7 +6,7 @@
public class StorageManager : MonoBehaviour public class StorageManager : MonoBehaviour
{ {
public GameObject managers; public CameraManager cameraManager;
private StorageReference storage; private StorageReference storage;
private DatabaseReference realtimeDB; private DatabaseReference realtimeDB;
@ -36,10 +36,8 @@ void Update()
public void UploadPhoto(string roomCode, string playerId, int question, int proposition) public void UploadPhoto(string roomCode, string playerId, int question, int proposition)
{ {
Texture2D photo = managers.GetComponent<CameraManager>().GetPhoto(); Texture2D photo = cameraManager.GetPhoto();
byte[] photoBytes = ImageConversion.EncodeToJPG(photo); byte[] photoBytes = ImageConversion.EncodeToJPG(photo);
GameManager game = managers.GetComponent<GameManager>();
string imageUuid = Guid.NewGuid().ToString(); string imageUuid = Guid.NewGuid().ToString();
StorageReference imageRef = storage.Child($"{roomCode}/{playerId}/{imageUuid}.png"); StorageReference imageRef = storage.Child($"{roomCode}/{playerId}/{imageUuid}.png");

View File

@ -38,7 +38,11 @@ private void Update()
return; return;
if (endOfTimer <= DateTime.Now) if (DateTime.Now < endOfTimer)
{
timerLabel.text = (DateTime.Now - endOfTimer).TotalSeconds.ToString("D2");
}
else
{ {
timerLabel.text = "0"; timerLabel.text = "0";
if (remainingQuestions.Count > 0) if (remainingQuestions.Count > 0)
@ -51,10 +55,6 @@ private void Update()
OnVoteEnded?.Invoke(); OnVoteEnded?.Invoke();
} }
} }
else
{
timerLabel.text = (DateTime.Now - endOfTimer).ToString("D2");
}
} }
@ -129,20 +129,25 @@ private void OnQuestionChanged(object sender, ValueChangedEventArgs _questionRef
} }
private void UpdateVoters() private void UpdateVoters()
{
if (currentQuestion.propositions[0] != null)
{ {
List<Player> playersThatHasVotedForFirstProposition = new List<Player>(); List<Player> playersThatHasVotedForFirstProposition = new List<Player>();
foreach (string playerId in currentQuestion.propositions[0].voters) foreach (string playerId in currentQuestion.propositions[0].voters)
{ {
playersThatHasVotedForFirstProposition.Add(currentPlayers[playerId]); playersThatHasVotedForFirstProposition.Add(currentPlayers[playerId]);
} }
proposition1.UpdateVoters(playersThatHasVotedForFirstProposition);
}
if (currentQuestion.propositions[1] != null)
{
List<Player> playersThatHasVotedForSecondProposition = new List<Player>(); List<Player> playersThatHasVotedForSecondProposition = new List<Player>();
foreach (string playerId in currentQuestion.propositions[1].voters) foreach (string playerId in currentQuestion.propositions[1].voters)
{ {
playersThatHasVotedForSecondProposition.Add(currentPlayers[playerId]); playersThatHasVotedForSecondProposition.Add(currentPlayers[playerId]);
} }
proposition1.UpdateVoters(playersThatHasVotedForFirstProposition);
proposition2.UpdateVoters(playersThatHasVotedForSecondProposition); proposition2.UpdateVoters(playersThatHasVotedForSecondProposition);
} }
}
} }