private void ShowQuestion() { RemoveAnswerButton(); QuestionsList questionData; if (currentlyHard) { randomQuestionIndex = UnityEngine.Random.Range(0, questionPoolHard.Length); questionData = questionPoolHard[randomQuestionIndex]; // select the hard questions } else { randomQuestionIndex = UnityEngine.Random.Range(0, questionPoolEasy.Length); questionData = questionPoolEasy[randomQuestionIndex]; // select the hard questions } questionDisplayText.text = questionData.question; for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.SetUp(questionData.answers[i]); answerButtonGameObject.transform.SetParent(answerButtonParent, false); // worldPositionStays argument set to false -> This will retain local orientation and scale answerButtonGameObjects.Add(answerButtonGameObject); } }
void ShowQuestion() { RemoveAnswerButtons(); // //int randomQuestionIndex = Random.Range(0, unansweredQuestions.Count); //currentQuestion = unansweredQuestions[randomQuestionIndex]; //questionText.text = currentQuestion.questionText; // 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); answerButtonGameObject.transform.localScale = Vector3.one; AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.SetUp(questionData.answers[i]); } }
public void ShowQuestion() { RemoveAnswerButtons(); QuestionData questionData = questionPool[questionIndex]; // Get the QuestionData for the current question questionText.text = ArabicFixer.Fix(questionData.title); // Update questionText with the correct text Debug.Log(questionData.title); if (questionData.type == "miniGame") { questionText.text = ArabicFixer.Fix(questionData.title); RemoveAnswerButtons(); StartCoroutine(changeObjectVisibility(MathCanvas, false)); MathObject.GetComponent <GameManager>().init(); } else { Debug.Log(questionData.answers.Length); 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; answerButtonGameObject.transform.position.Set(answerButtonGameObject.transform.position.x, answerButtonGameObject.transform.position.y, 0); 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 } } }
void ShowQuestion() { RemoveAnswerButtons(); scroll.value = 1; QuestionData questionData = questionPool[questionIndex]; // Get the QuestionData for the current question string questionSF = questionData.contenido.ToString(); questionSF = questionSF.Replace("\\n", "\n"); questionSF = questionSF.Replace("\\t", "\t"); if (questionData.textura != null) { Rect rec = new Rect(0, 0, questionData.textura.width, questionData.textura.height); Sprite spriteToUse = Sprite.Create(questionData.textura, rec, new Vector2(0.5f, 0.5f), 100); imageToDisplay.sprite = spriteToUse; imageToDisplay.rectTransform.sizeDelta = new Vector2(1080f, questionData.textura.height * 2); entrarImagen.interactable = true; } else { entrarImagen.interactable = false; } questionText.text = questionSF; // 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 ShowQuestions() { RemoveAnswerButtons(); QuestionData question = questionData[questionIndex]; questionText.text = question.questionText.ToLower(); for (int i = 0; i < question.answers.Length; i++) { GameObject answer = answerButtonPool.GetObject(); answer.transform.SetParent(answersPanel, false); answer.SetActive(true); answerButtonObjects.Add(answer); AnswerButton answerButton = answer.GetComponent <AnswerButton>(); if (i == 0) { if (roundNum == 0) { questionText.font = answerButton.star; } else { questionText.font = answerButton.lord; } } answerButton.SetUp(question.answers[i], roundNum); } }
private void ShowQuestion() { RemoveAnswerButtons(); if (Config.Instance.globalConfig.environment == Environment.PRODUCTION) // { randomIds.Shuffle(); } _timeRemaining = _baseTimeRemaining - (_currentRoundData.difficultyLevel * 2); timeRemainingSlider.maxValue = _timeRemaining; UpdateTimeRemainingDisplay(); QuestionData questionData = _questionPool[_questionIndex]; questionText.text = "Level " + _currentRoundData.difficultyLevel + ": " + questionData.questionText; for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); _answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent); answerButtonGameObject.transform.localScale = Vector3.one; AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.SetUp(questionData.answers[randomIds[i]]); } }
void ShowQuestion() { foto = GameObject.Find("foto").GetComponent <Image>(); Debug.Log(" nombre " + foto.name); RemoveAnswerButtons(); int pregunta = Random.Range(0, questionPool.Length); QuestionData questionData = questionPool[pregunta]; // Get the QuestionData for the current question questionText.text = questionData.questionText; // Update questionText with the correct text string filePath2 = Application.streamingAssetsPath + "/"; filePath2 = filePath2 + "" + questionData.imagen; //Debug.Log(" imagen" +questionData.imagen); //Debug.Log("direccion imagen" + filePath2); foto.sprite = Resources.Load <Sprite>(filePath2); 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() { RemoveAnswerButton(); questionData = questionPool[questionIndex]; questionDisplayText.text = questionData.questionText; audioDisplay.GetComponent <AudioPanel>().audioClipCommand.GetComponent <AudioController>().UnloadAudio(); // Manage Audio question. if (questionData.questionAudio != null && questionData.questionAudio != "") { audioDisplay.GetComponent <AudioPanel>().audioClipCommand.GetComponent <AudioController>().LoadAudio(questionData.questionAudio); audioDisplay.SetActive(true); } if (questionData.questionImage != null && questionData.questionImage != "") { imageDisplay.SetActive(true); imageDisplay.GetComponent <Image>().sprite = dataController.getImageSprite(questionData.questionImage); } else { imageDisplay.SetActive(false); } // There 2 types of answer: Button or InputField. if (questionData.questionType == "Input") { for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerInputGameObject = answerInputObjectPool.GetObject(); answerInputGameObjects.Add(answerInputGameObject); answerInputGameObject.transform.SetParent(answerInputParent); AnswerInput answerInput = answerInputGameObject.GetComponent <AnswerInput>(); answerInput.SetUp(questionData.answers[i]); } } else { 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]); } } dataController.debudText.text += "question display image : " + questionDisplay.GetComponent <Image>().sprite.name; }
// Update is called once per frame private void ShowQuestion() { RemoveAnswerQuestion(); QuestionData questionData = questionPool[questionIndex]; questionText.text = questionData.questionText; for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButGo = answerButGoPool.GetObject(); answerButGo.transform.SetParent(answerButParent); answerButGos.Add(answerButGo); AnswerButton answerBut = answerButGo.GetComponent <AnswerButton>(); answerBut.SetUp(questionData.answers[i]); } }
/// <summary> /// ramdomly pick a question from the pool and show /// </summary> public void ShowQuestion() { RemoveAnswerButtons(); // randomly select question from question pool int randomIndex = Random.Range(0, questionPool.Length); QuestionData questionData = questionPool[randomIndex]; questionDisplayText.text = questionData.questionText; 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 ShowQuestion() { RemoveAnswerButton(); QuestionData questionData = questionPool[questionIndex]; questionText.text = questionData.questionText; //for showing the button for (int i = 0; i < questionData.answers.Length; i++) { GameObject asbGO = answerButtonPool.GetObject(); asbGO.transform.SetParent(parentsPanel); answerButtonGO.Add(asbGO); AnswerButton answerButton = asbGO.GetComponent <AnswerButton>(); answerButton.SetUp(questionData.answers[i]); } }
private void ShowQuestion() { // for each question, player has 10s to answer timeRemaining = 15; RemoveAnswerButtons(); QuestionData questionData = questionPool[questionIndex]; questionDisplayText.text = questionData.questionText; for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButtonGameObject = answerButtonGameObjectPool.GetObject(); answerButtonGameObject.transform.SetParent(answerButtonParent); answerButtonGameObjects.Add(answerButtonGameObject); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.SetUp(questionData.answers[i]); } }
// Grabs the proper Question Pool depending on the artist and displays their questions private void ShowQuestion() { // Remove all answer buttons being used RemoveAnswerButtons(); QuestionData questionData = questionPool[questionIndex]; questionText.text = questionData.questionText; // Add the optional answers to the GameObject and set them up 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]); } }
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() { removeAnswerButtons(); QuestionData questionData = questionPool[questionIndex]; questionText.text = questionData.questionText; //part that puts answers in answer panel for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButtonGameObject = answerButtonPool.GetObject(); answerButtonGameObject.transform.SetParent(answerButtonHolder); answerButtonGameObjects.Add(answerButtonGameObject); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.SetUp(questionData.answers[i]); } }
void ShowQuestion() { 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); answerButtonGameObject.transform.localScale = Vector3.one; AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton>(); answerButton.SetUp(questionData.answers[i]); } }
private void ShowQuestions() { //Clear answer buttons RemoveAnswerButtons(); //Set question text QuestionData questionData = questionPool[questionIndex]; questionText.text = questionData.questionText; //Add answer buttons for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButtonObject = answerButtonPool.GetObject(); answerButtonObject.transform.SetParent(answerParent); answerButtonObjects.Add(answerButtonObject); AnswerButton answerButton = answerButtonObject.GetComponent <AnswerButton>(); answerButton.SetUp(questionData.answers[i]); } }
void ShowQuestion() { RemoveAnswerButtons(); //QuestionData questionData = questionPool[questionIndex]; // Get the QuestionData for the current question Question questionData = questionPool2[questionIndex]; questionText.text = questionData.question; // Update questionText with the correct text int questionCount = 2; if (questionData.answer3 == null || questionData.answer3 == "") { } else { questionCount++; } if (questionData.answer4 == null || questionData.answer4 == "") { } else { questionCount++; } for (int i = 0; i < questionCount; 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 answerButton.SetUp(questionData.allAnswers[i], questionData); } }
public int getQuestion() { List <QuestionData> listData = GameManager.instant.questionList; if (listData != null && listData.Count > 0) { questionIndex = Random.Range(0, listData.Count); questionData = listData [questionIndex]; textQuestion.text = questionData.questionText; // Debug.Log ("Cau hoi Tram dung: " + questionData.questionText); AnswerData[] answerList = questionData.answers; for (int i = 0; i < answerList.Length; i++) { GameObject answerGO = Instantiate(answerButton, Vector3.zero, Quaternion.identity, answerParent); AnswerButton answerBtn = answerGO.GetComponent <AnswerButton> (); answerBtn.SetUp(answerList[i]); } } else { questionIndex = -1; } return(questionIndex); }
void ShowQuestion(int whichquestion) { isRoundActive = true; while (answerButtonGameObjects.Count > 0) // Return all spawned AnswerButtons to the object pool { answerButtonObjectPool.ReturnObject(answerButtonGameObjects[0]); answerButtonGameObjects.RemoveAt(0); } QuestionData questionData = questionPool[whichquestion]; // 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 } }
public void ShowQuestion() { //Reset the missed answers text missedAnswerDisplay.text = ""; continueButton.SetActive(false); continueButtonLost.SetActive(false); roundCounter++; summaryDisplay.SetActive(false); winDisplay.SetActive(false); roundEndDisplay.SetActive(false); isRoundActive = true; questionDisplay.SetActive(true); //Start the timer timeRemaining = dataController.getCurrentRoundTime(); UpdateTimeRemainingDisplay(); //Set the starting score playerScore = 0; scoreDisplayText.text = "Score: " + playerScore.ToString(); //Set the round number at the top of screen to current round roundNumberText.text = "Round " + roundCounter; RemoveAnswerButtons(); //Set the current question to a random question questionIndex = unusedQuestions[Random.Range(0, unusedQuestions.Count)]; //Debug.Log ("Current q index = " + questionIndex); Question questionData = questionPool [questionIndex]; questionDisplayText.text = questionData.questions; //Display each answer button if (!next) { for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent, false); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton> (); //Setup the answerButtons on screen answerButton.SetUp(questionData.answers [i]); //Adding the current answers to a list currentAnswers.Add(answerButton.returnAnswer()); next = true; } } else { for (int i = 0; i < questionData.answers.Length; i++) { GameObject answerButtonGameObject = answerButtonObjectPool.GetObject(); answerButtonGameObjects.Add(answerButtonGameObject); answerButtonGameObject.transform.SetParent(answerButtonParent, false); AnswerButton answerButton = answerButtonGameObject.GetComponent <AnswerButton> (); //Setup the answerButtons on screen answerButton.SetUp(questionData.answers [6 - i]); //Adding the current answers to a list currentAnswers.Add(answerButton.returnAnswer()); next = false; } } //Remove the question that has been used from the list unusedQuestions.Remove(questionIndex); }