private void ShowQuestion() { RemoveAnswerButtons(); QuestionData questionData = questionPool[questionIndex]; questionDisplayText.text = questionData.questionText; for (int i = 0; i < questionData.answers.Length; i++) { timeRemaining = 10; GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent); if (questionData.clip != null) { AudioClip audio = questionData.clip; source.clip = audio; source.Play(); } else { source.Stop(); } AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.Setup(questionData.answers[i]); } }
IEnumerator AssignAnswerButtons(float time) { yield return(new WaitForSeconds(time)); // Code to execute after the delay QuestionData questionData = questionPool [questionIndex]; //Asign answers to boxes Random rnd = new Random(); //randomizes output var answersInRandomOrder = questionData.answers.OrderBy(x => randnum.Next()).ToArray(); for (int i = 0; i < answersInRandomOrder.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.Setup(answersInRandomOrder[i]); } //The question is done now, show button and play bg music spokenQuestion = true; bgMusic.Play(); Vector3 replayscale = new Vector3(1, 1, 1); replay.transform.localScale = replayscale; }
private void ShowQuestion() { questionPanel.SetActive(true); nextButton.SetActive(false); explanationButton.SetActive(false); questionIndex = Random.Range(0, questionPool.Length); RemoveAnswerButtons(); canAnswer = true; QuestionData questionData = questionPool[questionIndex]; questionDisplayText.text = questionData.questionText; for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.GetComponent <Image>().color = new Color32(255, 255, 255, 50); answerButton.Setup(questionData.answers[i]); } }
private void ShowQuestion() { RemoveAnswerButtons(); QuestionData questionData = questionPool[questionIndex]; questionText.text = questionData.colorName; questionDisplayBackgroundColor = new Color32( questionData.colorRGB[0], questionData.colorRGB[1], questionData.colorRGB[2], OBAQUE_VALUE); GameObject.Find("QuestionPanel").GetComponent <RawImage>().color = questionDisplayBackgroundColor; for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObject.transform.SetParent(answerButtonParent); answerButtonGameObjects.Add(answerButtonGameObject); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.Setup(questionData.answers[i]); } }
private void SetCurrentQuestion() { if (questionCount == questionPool.Length || healthCount == 0) { EndRound(); } else { RemoveAnswerButtons(); int randomQuestionIndex = random.Next(0, unansweredQuestions.Count); currentQuestion = unansweredQuestions[randomQuestionIndex]; questionTextDisplay.text = currentQuestion.question; for (int i = 0; i < currentQuestion.choices.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObject.transform.SetParent(answerButtonParent); answerButtonGameObjects.Add(answerButtonGameObject); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.Setup(currentQuestion.choices[i]); } unansweredQuestions.Remove(currentQuestion); } }
private void ShowQuestion() { RemoveAnswerButtons(); int random = Random.Range(0, questionPool.Length); while (usedValues.Contains(random)) { random = Random.Range(0, questionPool.Length); } QuestionData questionData = questionPool[random]; usedValues.Add(random); textoPergunta.text = questionData.textoDaPergunta; for (int i = 0; i < questionData.respostas.Length; i++) { GameObject answerButtongameObject = answerButtonObjectPool.GetObject(); answerButtongameObject.transform.SetParent(answerButtonParent); answerButtonGameObjects.Add(answerButtongameObject); AnswerButton answerButton = answerButtongameObject.GetComponent <AnswerButton>(); answerButton.Setup(questionData.respostas[i]); } }
private void ShowQuestion() { print(questionsList.Count); timeRemaining = 40f; RemoveAnswerButtons(); QuestionData questionData = questionsList[questionIndex]; questionDisplayText.text = questionData.questionText.Replace("NEWLINE", "\n"); List <AnswerData> wrongAnswersForSpecificQuestion = new List <AnswerData>(); for (int i = 0; i < 4; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); GameObject child = answerButtonGameObject.transform.GetChild(0).transform.GetChild(0).gameObject; if (child.GetComponent <Text>().text.Equals("-")) { child.GetComponent <Text>().text = abcd[i]; } answerButtonGameObject.transform.SetParent(answerButoonParent); answerButtonGameObject.transform.localScale = new Vector3(1f, 1f, 1f); answerButtonGameObjects.Add(answerButtonGameObject); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); if (i == 0) { answerButton.Setup(questionData.answers[0]); wrongAnswersForSpecificQuestion.Add(questionData.answers[0]); } else { int incorrectIndex = Random.Range(0, currentWrongData.Count); while (wrongAnswersForSpecificQuestion.Exists(x => x.answerText[0] == currentWrongData[incorrectIndex].answerText[0])) { incorrectIndex = Random.Range(0, currentWrongData.Count); } answerButton.Setup(currentWrongData[incorrectIndex]); wrongAnswersForSpecificQuestion.Add(currentWrongData[incorrectIndex]); } } }
private int answerNumber; // para manipular cuantos botones se crean // OPTIONAL en caso de que se decida que los parciales tengan tiempo activar //public Text timeQuiz; public void CreateButtonsAndInputs(Answer[] data, string idButton) { answerNumber = data.Length; for (int i = 0; i < answerNumber; i++) { GameObject answerButtonGameObject = Instantiate(prefabButton); answerButtonGameObject.transform.SetParent(answerButtonPanel); AnswerButton answerButton = answerButtonGameObject .GetComponent <AnswerButton>(); answerButton.Setup(data[i], idButton); } }
private void ShowQuestion() { RemoveButton(); Soalnya questionData = questionPool[QuestionIndex]; questionText.text = questionData.qouestion; for (int i = 0; i < questionData.answer.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.Setup(questionData.answer[i]); } }
private void ShowQuestion() { RemoveAnswerButtons(); //removing old answers so that we can display the new questions. QuestionData questionData = questionPool[questionIndex]; questionDisplayText.text = questionData.questionText; //displaying the question for (int i = 0; i < questionData.answers.Length; i++) //displaying the buttons { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent); AnswerButton answerButton = answerButtonGameObject.GetComponent<AnswerButton>(); answerButton.Setup(questionData.answers[i]); } }
private void ShowQuestion() { RemoveAnswerButtons(); QuestionData questionData = questionPool[questionIndex]; questionDisplayText.text = questionData.questionText; foreach (var answer in questionData.answers) { GameObject answerButtonRoot = answerButtonObjectPool.GetObject(); answerButtonRoot.transform.SetParent(answersPanel.transform, false); AnswerButton answerButton = answerButtonRoot.GetComponent <AnswerButton>(); answerButton.Setup(answer); } }
private void ShowQuestion() { RemoveAanswerButtons(); QuestionData questionData = questionPool [questionIndex]; questionText.text = questionData.questionText; for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButtonGameObjetc = answerButtonObjectPool.GetObject(); answerButtonGameObjetc.transform.SetParent(answerButtonParent); AnswerButton answerButton = answerButtonGameObjetc.GetComponent <AnswerButton> (); answerButton.Setup(questionData.answers [i]); } }
private void ShowAnswer() { RemoveAnswerButtons(); for (int i = 0; i < answerWord.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton> (); answerButton.setButtonIndex(i); answerButton.Setup(""); } }
// ********************************************************************** // private void SetupAnswerButtons() { // Remove old buttons and load new answer buttons RemoveAnswerButtons(); // send old answer button objects back to object pool // This will create an extra button for each possible answer for (int i = 0; i < GameController.control.trialPossibleAnswers.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObject.transform.SetParent(answerButtonParent, false); answerButtonGameObjects.Add(answerButtonGameObject); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.Setup(GameController.control.trialPossibleAnswers[i]); } }
private void ShowQuestion() //clear out any existing answer button and show questions { RemoveAnswerButtons(); QuestionData questionData = questionPool[questionIndex]; questionDisplayText.text = questionData.questionText; for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject();//get me another button which is not currently used answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.Setup(questionData.answers[i]); //pass to the answer } }
public void showQuestion() { RemoveAnswerButtons(); QuestionData questiondata = questionPool [questionIndex]; questionText.text = questiondata.QuestionText; for (int i = 0; i < questiondata.answers.Length; i++) { GameObject answerBtn = answerbtnObjPool.GetObject(); answerObjList.Add(answerBtn); answerBtn.transform.SetParent(answerbtnParent); AnswerButton answerbutton = answerBtn.GetComponent <AnswerButton> (); answerbutton.Setup(questiondata.answers [i]); } }
public void QuestionButtonClicked(string tileText, int mappedQuestionButtonIndex) { Debug.Log("Question button clicked = " + mappedQuestionButtonIndex); foreach (GameObject ansBtn in answerButtonGameObjects) { AnswerButton answerButton = ansBtn.GetComponent <AnswerButton> (); if (answerButton.answerText.text == "") { answerButton.Setup(tileText); answerButton.SetMappedQuestionButtonIndex(mappedQuestionButtonIndex); checkIfAnswerIsComplete(); break; } } }
private void ShowInstruction() { RemoteAnswerButtons(); InstructionData instructionData = instructionPool [instructionIndex]; instructionDisplayText.text = instructionData.instructionText; for (int i = 0; i < instructionData.answers.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton> (); answerButton.Setup(instructionData.answers[i]); } }
private void ShowQuestion() { RemoveAnswerButtons(); QuestionDate questionDate = questionPool[questionIndex]; questionDisplayText.text = questionDate.questionText; for (int i = 0; i < questionDate.answers.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObject.transform.SetParent(answerButtonParent); answerButtonGameObject.name = i.ToString(); answerButtonGameObjects.Add(answerButtonGameObject); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.Setup(questionDate.answers[i]); } }
} //end RemoveAnswerButtons private void ShowQuestion() { RemoveAnswerButtons(); QuestionData questionData = questionPool [questionIndex]; //reach in pool, get question and display in UI questionDisplayText.text = questionData.questionText; for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton> (); answerButton.Setup(questionData.answers [i]); } //end for } //end ShowQuestion
private void ShowQuestion() { RemoveAnswerButtons(); QuestionData questionData = questionPool[questionIndex]; questionDisplayText.text = questionData.questionText; for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent, false); answerButtonGameObject.transform.localScale = new Vector3(1, 1, 1); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.Setup(questionData.answers[i]); } }
void ShowQuestion() { RemoveAnswerButtons(); QuestionData questionData = questionPool[questionIndex]; // Get the QuestionData for the current question questionText.text = questionData.questionText; // Update questionText with the correct text for (int i = 0; i < questionData.answers.Length; i++) // For every AnswerData in the current QuestionData... { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); // Spawn an AnswerButton from the object pool answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent); answerButtonGameObject.transform.localScale = Vector3.one; AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.Setup(questionData.answers[i]); // Pass the AnswerData to the AnswerButton so the AnswerButton knows what text to display and whether it is the correct answer } }
private void ShowQuestion() { //Remove old answers get current question and display the text RemoveAnswerButtons(); QuestionData questionData = questionPool[questionIndex]; questionDisplayText.text = questionData.questionText; //Get all answers for the question, create new buttons for each and add them to the answerButtonParent object(AnswerPanel) for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent); //we get a reference to the answer button then use its attatched script to set the answer AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); //Give the gameobject an answer button component answerButton.Setup(questionData.answers[i]); } }
private void ShowQuestion() { RemoveAnswerButtons(); QuestionData questionData = new QuestionData(); questionData = questionPool[questionIndex]; questionDisplayText.text = questionData.questionText; for (int i = 0; i < questionData.answers.Length; i++) { Debug.Log("Button wird erstellt"); GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.Setup(questionData.answers[i]); } }
private void ShowQuestion() { // First remove old answer buttons RemoveAnswerButtons(); // Get question from pool questionData = questionPool [nextQuestionIndex]; questionText.text = questionData.QuestionText; timeRemaining = questionData.TimeLimit; // Create N answer buttons for (int i = 0; i < questionData.Answers.Count; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObject.transform.SetParent(answerButtonParent, false); answerButtonGameObjects.Add(answerButtonGameObject); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton> (); answerButton.Setup(questionData.Answers [i]); } }
public void ShowQuestion() { isRoundActive = true; UIPanel.SetActive(true); RemoveAnswerButtons(); QuestionData questionData = questionPool [questionIndex]; questionText.text = questionData.questionText; for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.Setup(questionData.answers[i]); } }
private void ShowQuestion() { RemoveAnswerButtons(); AudioData questionData = audioPool [questionIndex]; audioSource = audioButton.GetComponent <AudioSource>(); audioSource.clip = questionData.questionAudio; audioSource.Play(); for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.transform.localScale.Set(1, 1, 1); answerButton.Setup(questionData.answers[i]); } }
private void ShowQuestions() { RemoveAnswerButtons(); QuestionData currentQuestion = question [questionIndex]; questionDisplay.text = currentQuestion.questionText; //GameObject buttonObject = null; foreach (AnswerData answer in currentQuestion.answers) { GameObject buttonObject = answerButtonPool.GetObject(); buttonObject.transform.SetParent(answerButtonParentTransform); AnswerButton answerButton = buttonObject.GetComponent <AnswerButton> (); answerButton.Setup(answer); answerButtonObject.Add(buttonObject); } }
public void ShowQuestion(QuestionData question) { RemoveAnswerButtons(); QuestionData questionData = question; questionDisplayText.text = questionData.questionText; for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.Setup(questionData.answers[i]); } triviaBoardImage.color = normalColor; triviaAnimator.SetBool("isOpen", true); }
private void ShowQuestion() { RemoveAnswerButton(); QuestionData questionData = questionPool[questionIndex]; // display text question questionText.text = questionData.questionText; // init answer button for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObject.transform.SetParent(answerButtonParent); // add button to array answerButtonGameObjects.Add(answerButtonGameObject); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.Setup(questionData.answers[i]); } }