diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index e79e370..3571c2f 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -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.questions = null; - myRoom.currentQuestionId = string.Empty; + myRoom.currentQuestionId = 0; string json = JsonUtility.ToJson(myRoom); myOnlineRoom.SetRawJsonValueAsync(json).ContinueWithOnMainThread(task => @@ -477,7 +490,7 @@ public void onClickSamePlayers() public void onClickNewPlayers() { myRoom.currentState = (int)GameState.EnteringName; - myRoom.currentQuestionId = string.Empty; + myRoom.currentQuestionId = 0; myRoom.questions = null; myRoom.players = null; string json = JsonUtility.ToJson(myRoom); @@ -494,8 +507,7 @@ public void onClickNewPlayers() public void OnClickProposition(int propositionNumber) { - int currentQuestionId = Int32.Parse(myRoom.currentQuestionId); - List voters = myRoom.questions[currentQuestionId].propositions[propositionNumber].voters.ToList(); + List voters = myRoom.questions[myRoom.currentQuestionId].propositions[propositionNumber].voters.ToList(); voters.Add(currentPlayer.id); myOnlineRoom.Child("questions").Child(myRoom.currentQuestionId.ToString()).Child("propositions").Child(propositionNumber.ToString()).Child("voters").SetValueAsync(voters); }