fix: stop sending request to server 60time per seconds

This commit is contained in:
Fangh 2024-01-29 23:40:38 +01:00
parent 61bdd410fe
commit 6898ac3a84
3 changed files with 6 additions and 3 deletions

View File

@ -77,7 +77,7 @@ private void Update()
private void SendRoomState(GameState _newState) private void SendRoomState(GameState _newState)
{ {
Debug.Log($"sending to RTDB that we are now in the {_newState} state", this); //Debug.Log($"sending to RTDB that we are now in the {_newState} state", this);
realtimeDB.Child("rooms").Child(myRoom.code).Child("currentState").SetValueAsync((int)_newState); realtimeDB.Child("rooms").Child(myRoom.code).Child("currentState").SetValueAsync((int)_newState);
} }

View File

@ -54,6 +54,8 @@ private void Update()
else else
{ {
OnVoteEnded?.Invoke(); OnVoteEnded?.Invoke();
OnVoteEnded = null;
gameObject.SetActive(false);
} }
} }
} }

View File

@ -36,7 +36,6 @@ public void OnRoomUpdate(Room _myRoom)
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
//while MakeProposition State //while MakeProposition State
if (endOfPropositionDate != DateTime.MinValue) if (endOfPropositionDate != DateTime.MinValue)
{ {
@ -46,6 +45,8 @@ void Update()
if (duration.TotalMilliseconds <= 0 || allPlayersHasProposedTwoPictures) if (duration.TotalMilliseconds <= 0 || allPlayersHasProposedTwoPictures)
{ {
OnPropositionFinish?.Invoke(); OnPropositionFinish?.Invoke();
OnPropositionFinish = null;
gameObject.SetActive(false);
return; return;
} }
@ -103,7 +104,7 @@ private void CheckPlayersWhoHaveProposed()
playerLabels.Find(x => x.text == player.name).color = Color.green; playerLabels.Find(x => x.text == player.name).color = Color.green;
playersIdWhoHaveProposed.Add(player.id); playersIdWhoHaveProposed.Add(player.id);
} }
Debug.Log($"{playersIdWhoHaveProposed.Count}/{myRoom.players.Count} players have answered.", this); //Debug.Log($"{playersIdWhoHaveProposed.Count}/{myRoom.players.Count} players have answered.", this);
if(playersIdWhoHaveProposed.Count == myRoom.players.Count) if(playersIdWhoHaveProposed.Count == myRoom.players.Count)
{ {
allPlayersHasProposedTwoPictures = true; allPlayersHasProposedTwoPictures = true;