fix: when 2 photos has been taken, should go to waiting page

This commit is contained in:
Fangh 2024-01-29 20:50:32 +01:00
parent c46d35df1b
commit 489102c948
2 changed files with 30 additions and 60 deletions

View File

@ -131,7 +131,6 @@ private void Update()
} }
private void Initialize() private void Initialize()
{ {
FirebaseInitializer.Instance.onFirebaseReady -= Initialize; FirebaseInitializer.Instance.onFirebaseReady -= Initialize;
@ -276,50 +275,6 @@ public void StartGame()
} }
} }
/// <summary>
/// Dislay on the screen the current prompt ask to you and another player
/// Also show all the camera stuff
/// </summary>
/// <param name="_prompt">The prompt to display</param>
public void MakeAProposition(Prompt _prompt)
{
//currentState = GameState.MakeProposition;
}
/// <summary>
/// Create a proposition from the picture taken and send it to server.
/// Then go to next proposition (if any) or the page "WaitingForOtherPlayers"
/// </summary>
public void SubmitProposition()
{
Proposition temp = new Proposition();
}
/// <summary>
/// Display the voting page
/// </summary>
public void StartToVote()
{
}
/// <summary>
/// Choose one result and send it to the server
/// Then go to the next vote (if any) or to the page "WaitingForOtherPlayers"
/// </summary>
public void Vote()
{
}
/// <summary>
/// Display the UI of the end screen
/// </summary>
public void DisplayEndScreen()
{
}
/// <summary> /// <summary>
/// Automatically called when something change in your room /// Automatically called when something change in your room
/// </summary> /// </summary>
@ -390,11 +345,6 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
} }
case (int)GameState.PropositionsSent: case (int)GameState.PropositionsSent:
{ {
if (TakePicture.activeInHierarchy)
{
TakePicture.SetActive(false);
WaitingOtherPlayers.SetActive(true);
}
break; break;
} }
case (int)GameState.MakeVote: case (int)GameState.MakeVote:
@ -422,6 +372,22 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
} }
} }
/// <summary>
/// Call this to wait for other players
/// </summary>
public void WaitForPlayers()
{
if (TakePicture.activeInHierarchy)
{
TakePicture.SetActive(false);
}
if(VotePicture.activeInHierarchy)
{
VotePicture.SetActive(false);
}
WaitingOtherPlayers.SetActive(true);
}
private void UpdateDisplayedListUser(List<Player> players) private void UpdateDisplayedListUser(List<Player> players)
{ {

View File

@ -10,7 +10,7 @@ public class QuestionHandler : MonoBehaviour
public TextMeshProUGUI explainText; public TextMeshProUGUI explainText;
public PromptList promptList; public PromptList promptList;
private List<Question> player2questions; private List<Question> player2questions;
private int currentQuestion = 1; private int currentQuestion = 0;
void OnEnable() void OnEnable()
{ {
@ -22,12 +22,12 @@ void OnEnable()
void OnDisable() void OnDisable()
{ {
player2questions = null; player2questions = null;
currentQuestion = 1; currentQuestion = 0;
} }
void Redraw(int currentQuestion) void Redraw(int currentQuestion)
{ {
Prompt prompt = promptList.prompts.Find(x => x.id == player2questions[currentQuestion - 1].promptId); Prompt prompt = promptList.prompts.Find(x => x.id == player2questions[currentQuestion].promptId);
Debug.Log(JsonUtility.ToJson(prompt)); Debug.Log(JsonUtility.ToJson(prompt));
explainText.SetText(prompt.en); explainText.SetText(prompt.en);
@ -37,23 +37,27 @@ void Redraw(int currentQuestion)
int GetPropRef(Player player) int GetPropRef(Player player)
{ {
return gameManager.myRoom.questions[currentQuestion - 1].propositions.First(x => x.Value.owner.id == player.id).Key; return gameManager.myRoom.questions[currentQuestion].propositions.First(x => x.Value.owner.id == player.id).Key;
} }
public void OnSubmitButton() public void OnSubmitButton()
{ {
StorageManager storageManager = managers.GetComponent<StorageManager>(); managers.GetComponent<StorageManager>().UploadPhoto(
storageManager.UploadPhoto(
gameManager.myRoom.code, gameManager.myRoom.code,
gameManager.currentPlayer.id, gameManager.currentPlayer.id,
currentQuestion -1, currentQuestion,
GetPropRef(gameManager.currentPlayer)); GetPropRef(gameManager.currentPlayer));
if (currentQuestion < 2) { if (currentQuestion == 1)
{
gameManager.myRoom.currentState = (int)GameState.PropositionsSent;
gameManager.WaitForPlayers();
return;
}
else
{
currentQuestion++; currentQuestion++;
Redraw(currentQuestion); Redraw(currentQuestion);
} else {
gameManager.myRoom.currentState = (int) GameState.PropositionsSent;
} }
} }