Compare commits

...

2 Commits

Author SHA1 Message Date
686b00b8d5 Merge branch 'main' of ssh://patema.crystalyx.net:2222/GameJams/Snaparazzi 2024-01-28 17:36:17 +01:00
5e58f33ea1 fix merge 2024-01-28 17:36:00 +01:00

View File

@ -115,6 +115,19 @@ private void Update()
} }
} }
if (myRoom.currentState == (int)GameState.MakeVote && endOfViewDate != DateTime.MinValue)
{
TimeSpan duration = endOfViewDate - DateTime.Now;
counterMakeProposition.text = ((int)duration.TotalSeconds).ToString("D1");
if (duration.TotalMilliseconds <= 0)
{
Debug.Log("It's time to finish proposition !");
endOfViewDate = DateTime.MinValue;
}
}
} }
@ -462,7 +475,7 @@ public void onClickSamePlayers()
{ {
myRoom.currentState = (int)GameState.Explanation; myRoom.currentState = (int)GameState.Explanation;
myRoom.questions = null; myRoom.questions = null;
myRoom.currentQuestionId = string.Empty; myRoom.currentQuestionId = 0;
string json = JsonUtility.ToJson(myRoom); string json = JsonUtility.ToJson(myRoom);
myOnlineRoom.SetRawJsonValueAsync(json).ContinueWithOnMainThread(task => myOnlineRoom.SetRawJsonValueAsync(json).ContinueWithOnMainThread(task =>
@ -477,7 +490,7 @@ public void onClickSamePlayers()
public void onClickNewPlayers() public void onClickNewPlayers()
{ {
myRoom.currentState = (int)GameState.EnteringName; myRoom.currentState = (int)GameState.EnteringName;
myRoom.currentQuestionId = string.Empty; myRoom.currentQuestionId = 0;
myRoom.questions = null; myRoom.questions = null;
myRoom.players = null; myRoom.players = null;
string json = JsonUtility.ToJson(myRoom); string json = JsonUtility.ToJson(myRoom);
@ -494,8 +507,7 @@ public void onClickNewPlayers()
public void OnClickProposition(int propositionNumber) public void OnClickProposition(int propositionNumber)
{ {
int currentQuestionId = Int32.Parse(myRoom.currentQuestionId); List<string> voters = myRoom.questions[myRoom.currentQuestionId].propositions[propositionNumber].voters.ToList<string>();
List<string> voters = myRoom.questions[currentQuestionId].propositions[propositionNumber].voters.ToList<string>();
voters.Add(currentPlayer.id); voters.Add(currentPlayer.id);
myOnlineRoom.Child("questions").Child(myRoom.currentQuestionId.ToString()).Child("propositions").Child(propositionNumber.ToString()).Child("voters").SetValueAsync(voters); myOnlineRoom.Child("questions").Child(myRoom.currentQuestionId.ToString()).Child("propositions").Child(propositionNumber.ToString()).Child("voters").SetValueAsync(voters);
} }