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()
{
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>
/// Automatically called when something change in your room
/// </summary>
@ -390,11 +345,6 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
}
case (int)GameState.PropositionsSent:
{
if (TakePicture.activeInHierarchy)
{
TakePicture.SetActive(false);
WaitingOtherPlayers.SetActive(true);
}
break;
}
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)
{

View File

@ -10,7 +10,7 @@ public class QuestionHandler : MonoBehaviour
public TextMeshProUGUI explainText;
public PromptList promptList;
private List<Question> player2questions;
private int currentQuestion = 1;
private int currentQuestion = 0;
void OnEnable()
{
@ -22,12 +22,12 @@ void OnEnable()
void OnDisable()
{
player2questions = null;
currentQuestion = 1;
currentQuestion = 0;
}
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));
explainText.SetText(prompt.en);
@ -37,23 +37,27 @@ void Redraw(int currentQuestion)
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()
{
StorageManager storageManager = managers.GetComponent<StorageManager>();
storageManager.UploadPhoto(
managers.GetComponent<StorageManager>().UploadPhoto(
gameManager.myRoom.code,
gameManager.currentPlayer.id,
currentQuestion -1,
currentQuestion,
GetPropRef(gameManager.currentPlayer));
if (currentQuestion < 2) {
if (currentQuestion == 1)
{
gameManager.myRoom.currentState = (int)GameState.PropositionsSent;
gameManager.WaitForPlayers();
return;
}
else
{
currentQuestion++;
Redraw(currentQuestion);
} else {
gameManager.myRoom.currentState = (int) GameState.PropositionsSent;
}
}