This commit is contained in:
Michel Roux 2024-01-28 03:08:39 +01:00
parent c84cb35bfe
commit 1e97dc0182

View File

@ -85,6 +85,7 @@ private void Update()
if (duration.TotalMilliseconds <= 0) if (duration.TotalMilliseconds <= 0)
{ {
Debug.Log("It's time to make proposition !", this);
SendRoomState(GameState.MakeProposition); SendRoomState(GameState.MakeProposition);
} }
} }
@ -103,23 +104,13 @@ private void Update()
{ {
//check if this player has send 2 propositions //check if this player has send 2 propositions
bool playerHasAnswerBoth = true; bool playerHasAnswerBoth = true;
//Debug.Log($"trying to check if player {labelByID.Key} has send 2 propositions");
//Debug.Log($"player {labelByID.Key} has send {propositionsPerPlayers[labelByID.Key].Length} propositions");
if (propositionsPerPlayers[labelByID.Key].Length < 2)
{
playerHasAnswerBoth = false;
}
else
{
foreach (Proposition p in propositionsPerPlayers[labelByID.Key]) foreach (Proposition p in propositionsPerPlayers[labelByID.Key])
{ {
if (string.IsNullOrEmpty(p.photoUrl)) if (string.IsNullOrEmpty(p.photoUrl))
{ {
Debug.Log($"player {labelByID.Key} proposition URL : {p.photoUrl}");
playerHasAnswerBoth = false; playerHasAnswerBoth = false;
} }
} }
}
//if its the case //if its the case
if (playerHasAnswerBoth) if (playerHasAnswerBoth)
{ {
@ -266,7 +257,6 @@ public void HostHasStartedGame()
waitingForPlayersPage.SetActive(false); waitingForPlayersPage.SetActive(false);
endOfPropositionDate = DateTime.Now.AddSeconds(propositionTime); endOfPropositionDate = DateTime.Now.AddSeconds(propositionTime);
propositionLabelsByID.Clear(); propositionLabelsByID.Clear();
//display only correct numbers of labels //display only correct numbers of labels
@ -274,7 +264,6 @@ public void HostHasStartedGame()
{ {
TextMeshProUGUI tmp = waitingForPropositionsLabels[i]; TextMeshProUGUI tmp = waitingForPropositionsLabels[i];
tmp.gameObject.SetActive(i < myRoom.players.Count); tmp.gameObject.SetActive(i < myRoom.players.Count);
Debug.Log($"toggling {tmp.gameObject.name} accordingly to its player connection");
} }
//registers the labels per player ID //registers the labels per player ID
@ -282,8 +271,7 @@ public void HostHasStartedGame()
for (int i = 0; i < orderedPlayers.Count; i++) for (int i = 0; i < orderedPlayers.Count; i++)
{ {
propositionLabelsByID.Add(orderedPlayers[i].id, waitingForPropositionsLabels[i]); propositionLabelsByID.Add(orderedPlayers[i].id, waitingForPropositionsLabels[i]);
waitingForPropositionsLabels[i].text = orderedPlayers[i].name; waitingForPlayersLabels[i].text = orderedPlayers[i].name;
Debug.Log($"{waitingForPropositionsLabels[i].name} label should be {orderedPlayers[i].name}");
} }
//Register all propositions of each players //Register all propositions of each players
@ -291,8 +279,9 @@ public void HostHasStartedGame()
{ {
List<Proposition> propositionsForPlayer = myRoom.GetPropositionsByPlayer(p); List<Proposition> propositionsForPlayer = myRoom.GetPropositionsByPlayer(p);
propositionsPerPlayers.Add(p.id, propositionsForPlayer.ToArray()); propositionsPerPlayers.Add(p.id, propositionsForPlayer.ToArray());
Debug.Log($"registering propositions for player {p.name}");
} }
} }
public void GeneratePrompts() public void GeneratePrompts()
@ -313,9 +302,7 @@ public void GeneratePrompts()
creationDate = DateTime.Now.ToOADate() creationDate = DateTime.Now.ToOADate()
}); });
fullPlayers.RemoveAt(0); for (int i = 1; i < fullPlayers.Count(); i++)
for (int i = 0; i < fullPlayers.Count(); i++)
{ {
Player secondPlayer = fullPlayers[i]; Player secondPlayer = fullPlayers[i];
@ -412,10 +399,6 @@ private void OnNewGameStateStarted()
explanationPage.SetActive(true); explanationPage.SetActive(true);
endOfExplanationDate = DateTime.Now.AddSeconds(explanationTime); endOfExplanationDate = DateTime.Now.AddSeconds(explanationTime);
AudioSource.PlayClipAtPoint(counterSFX, Vector3.zero); AudioSource.PlayClipAtPoint(counterSFX, Vector3.zero);
//generate all the questions during the explanation
GeneratePrompts();
break; break;
case (int)GameState.MakeProposition: case (int)GameState.MakeProposition:
Debug.Log("New State : MakeProposition"); Debug.Log("New State : MakeProposition");
@ -431,7 +414,6 @@ private void OnNewGameStateStarted()
/// </summary> /// </summary>
private void CheckPlayersPropositions() private void CheckPlayersPropositions()
{ {
Debug.Log("Check every Players Propositions");
allPlayersHasProposedTwoPictures = true; allPlayersHasProposedTwoPictures = true;
foreach (var propositionsByPlayer in propositionsPerPlayers) foreach (var propositionsByPlayer in propositionsPerPlayers)
@ -439,13 +421,10 @@ private void CheckPlayersPropositions()
foreach (Proposition p in propositionsByPlayer.Value) foreach (Proposition p in propositionsByPlayer.Value)
{ {
if (string.IsNullOrEmpty(p.photoUrl)) if (string.IsNullOrEmpty(p.photoUrl))
{
Debug.Log($"player {p.owner} has a proposition without an URL");
allPlayersHasProposedTwoPictures = false; allPlayersHasProposedTwoPictures = false;
} }
} }
} }
}
/// <summary> /// <summary>