public void ChangeQuestion(QuestionDataClient questionData) { questionLabel.text = questionData.Question; for (int i = 0; i < 4; i++) { if (i < questionData.Answers.Length) { answerLabels[i].text = questionData.Answers[i]; answerLabels[i].enabled = true; answerImages[i].enabled = true; } else { answerLabels[i].enabled = false; answerImages[i].enabled = false; } } }
public void RpcChangeQuestion(QuestionDataClient questionData) { if (!isLocalPlayer) { return; } if (correctAnswerIndex != chosenAnswerIndex && chosenAnswerIndex >= 0) { uiManager.ColorAnswer(chosenAnswerIndex); } if (correctAnswerIndex >= 0) { uiManager.ColorAnswer(correctAnswerIndex); } uiManager.ChangeQuestion(questionData); correctAnswerIndex = -1; chosenAnswerIndex = -1; }
private IEnumerator SendQuestionToClients() { yield return(QuestionReceiver.GetQuestion((returnedQuestionData) => { currentQuestionData = returnedQuestionData; })); currentQuestionDataClient = new QuestionDataClient(currentQuestionData.question, currentQuestionData.shuffled_answers); playersAnswered = 0; for (int i = 0; i < playerIds.Count; i++) { if (players[playerIds[i]] == null) { continue; } int playerIndex = playerIds[i]; SendQuestionToClient(players[playerIndex], currentQuestionDataClient); } }
private void SendQuestionToClient(PlayerData playerData, QuestionDataClient question) { playerData.chosenAnswerIndex = -1; playerData.triviaGameManagerClient.RpcChangeQuestion(question); }