fix: (I hope) switch to waiting screen after vote (and clean some debug log)

This commit is contained in:
Fangh 2024-01-29 23:00:10 +01:00
parent 6b56da648c
commit 884d2a0e2d
6 changed files with 16 additions and 19 deletions

View File

@ -30,7 +30,7 @@ private void Awake()
public void ChangeMusic(MusicTitle _title) public void ChangeMusic(MusicTitle _title)
{ {
Debug.Log($"changing music to {_title}"); //Debug.Log($"changing music to {_title}");
musicSource.clip = musics.Find(x => x.title == _title).clip; musicSource.clip = musics.Find(x => x.title == _title).clip;
musicSource.Play(); musicSource.Play();
} }
@ -42,7 +42,7 @@ public void StopMusic()
public void PlaySFX(AudioClip _clip) public void PlaySFX(AudioClip _clip)
{ {
Debug.Log($"playing {_clip.name} SFX"); //Debug.Log($"playing {_clip.name} SFX");
sfxSource.PlayOneShot(_clip); sfxSource.PlayOneShot(_clip);
} }

View File

@ -360,10 +360,6 @@ private void OnNewGameState()
} }
break; break;
} }
case (int)GameState.PropositionsSent:
{
break;
}
case (int)GameState.MakeVote: case (int)GameState.MakeVote:
{ {
if (TakePicture.activeInHierarchy || WaitingOtherPlayers.activeInHierarchy) if (TakePicture.activeInHierarchy || WaitingOtherPlayers.activeInHierarchy)
@ -529,7 +525,6 @@ public void OnClickProposition(int propositionNumber)
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);
myRoom.currentState = (int)GameState.VoteSent;
WaitingOtherPlayers.SetActive(true); WaitingOtherPlayers.SetActive(true);
VotePicture.SetActive(false); VotePicture.SetActive(false);
} }
@ -543,8 +538,6 @@ public enum GameState
WaitingForOtherPlayersToJoin = 1, WaitingForOtherPlayersToJoin = 1,
Explanation = 2, Explanation = 2,
MakeProposition = 3, MakeProposition = 3,
PropositionsSent = 4, MakeVote = 4,
MakeVote = 5, Score = 5
VoteSent = 6,
Score = 7
} }

View File

@ -20,7 +20,7 @@ public class PropositionFrame : MonoBehaviour
public void Initialize(Proposition _proposition) public void Initialize(Proposition _proposition)
{ {
Debug.Log($"Initializing {_proposition.owner.name}'s proposition", this); //Debug.Log($"Initializing {_proposition.owner.name}'s proposition", this);
proposition = _proposition; proposition = _proposition;
playerName.text = proposition.owner.name; playerName.text = proposition.owner.name;
@ -34,12 +34,12 @@ public void Initialize(Proposition _proposition)
/// <param name="_gsUrl"></param> /// <param name="_gsUrl"></param>
private void DisplayPicture(string _gsUrl) private void DisplayPicture(string _gsUrl)
{ {
Debug.Log($"Google Storage URL : {_gsUrl}"); //Debug.Log($"Google Storage URL : {_gsUrl}");
StorageManager.ConvertGoogleStorageURLToHttpsUrl(_gsUrl, _url => StorageManager.ConvertGoogleStorageURLToHttpsUrl(_gsUrl, _url =>
{ {
StartCoroutine(StorageManager.DownloadImage_Coroutine(_url, _texture => StartCoroutine(StorageManager.DownloadImage_Coroutine(_url, _texture =>
{ {
Debug.Log("Set texture in the raw image"); //Debug.Log("Set texture in the raw image");
picture.texture = _texture; picture.texture = _texture;
})); }));
}); });
@ -47,7 +47,7 @@ private void DisplayPicture(string _gsUrl)
public void UpdateVoters(List<Player> _newVoters) public void UpdateVoters(List<Player> _newVoters)
{ {
Debug.Log($"There are some new voters for {proposition.owner}'s proposition", this); //Debug.Log($"There are some new voters for {proposition.owner}'s proposition", this);
foreach (Player p in _newVoters) foreach (Player p in _newVoters)
{ {
if (!currentVoters.Contains(p)) if (!currentVoters.Contains(p))

View File

@ -305,7 +305,7 @@ private void UpdateConnectedPlayerList(List<Player> _players)
AudioManager.Instance.PlaySFX(playerJoinSFX); AudioManager.Instance.PlaySFX(playerJoinSFX);
ResetAllPlayerLabels(); ResetAllPlayerLabels();
Debug.Log($"players count = {_players.Count}"); //Debug.Log($"players count = {_players.Count}");
List<Player> orderedPlayers = _players.OrderBy(x => x.creationDate).ToList(); List<Player> orderedPlayers = _players.OrderBy(x => x.creationDate).ToList();
for (int i = 0; i < orderedPlayers.Count; i++) for (int i = 0; i < orderedPlayers.Count; i++)
{ {
@ -316,7 +316,7 @@ private void UpdateConnectedPlayerList(List<Player> _players)
private void QueryRoomsInDatabase(Action<List<Room>> callback) private void QueryRoomsInDatabase(Action<List<Room>> callback)
{ {
Debug.Log("Querying rooms from the database", this); //Debug.Log("Querying rooms from the database", this);
realtimeDB.Child("rooms").GetValueAsync().ContinueWithOnMainThread(task => realtimeDB.Child("rooms").GetValueAsync().ContinueWithOnMainThread(task =>
{ {
if (task.IsFaulted) if (task.IsFaulted)

View File

@ -99,7 +99,7 @@ public static void ConvertGoogleStorageURLToHttpsUrl(string _gsURL, Action<strin
} }
else else
{ {
Debug.Log("Image HTTPS URL: " + task.Result); //Debug.Log("Image HTTPS URL: " + task.Result);
callback_OnURLFound?.Invoke(task.Result.ToString()); callback_OnURLFound?.Invoke(task.Result.ToString());
} }
}); });

View File

@ -77,12 +77,16 @@ public void ShowVotingPage(DatabaseReference _roomRef, Dictionary<string, Player
} }
currentQuestion = remainingQuestions.Dequeue(); currentQuestion = remainingQuestions.Dequeue();
roomRef.Child("currentQuestionId").SetValueAsync(currentQuestion.index);
ShowQuestion(); ShowQuestion();
} }
/// <summary>
/// Display next question on screen
/// </summary>
void ShowQuestion() void ShowQuestion()
{ {
roomRef.Child("currentQuestionId").SetValueAsync(currentQuestion.index);
Debug.Log($"Show Question {currentQuestion.promptId}", this); Debug.Log($"Show Question {currentQuestion.promptId}", this);
Prompt currentPrompt = promptList.GetPromptById(currentQuestion.promptId); Prompt currentPrompt = promptList.GetPromptById(currentQuestion.promptId);
currentPromptLabel.text = currentPrompt.en; currentPromptLabel.text = currentPrompt.en;