Esempio n. 1
0
    private IEnumerator OnOptionButtonPressed(bool PressedButton)
    {
        if (PressedButton)
        {
            targetQuestionCardScript.SetQuestionText("Respuesta correcta");
            AudioManager.instance.PlayButtonSound(true);
            yield return(new WaitForSeconds(3.5f));

            GameManager.instance.OnCorrectAnswer();
        }
        else
        {
            targetQuestionCardScript.SetQuestionText("Respuesta incorrecta");
            AudioManager.instance.PlayButtonSound(false);
            yield return(new WaitForSeconds(3.5f));

            GameManager.instance.OnWrongAnswer();
        }
    }
Esempio n. 2
0
    public void StartPlayFlow()
    {
        if (this.optionButtonList.Count > 0)
        {
            for (int index = 0; index < this.optionButtonList.Count; index++)
            {
                gameObjectButtonList[index].onButtonPressed -= AfterOptionIsPressed;
                OnAnimationEnded -= gameObjectButtonList[index].InteractableAtEndofAnimation;
                Destroy(this.optionButtonList[index].gameObject);
            }

            this.optionButtonList.Clear();
            this.gameObjectButtonList.Clear();
        }

        QuestionManager.Categories targetCategory = QuestionManager.instance.GetRandomCategory();
        targetQuestionCardScript = carouselBehaviour.StartSwipeToCategory(targetCategory).GetComponent <QuestionCard>();
        QuestionAndAnswers targetQuestionData = QuestionManager.instance.GetRandomQuestionByCategory(targetCategory);

        targetQuestionCardScript.SetQuestionText(targetQuestionData.question);

        int RandomButton     = Random.Range(0, 4);
        int wrongAnswerIndex = 0;

        for (int index = 0; index < 4; index++)
        {
            if (index == RandomButton)
            {
                OptionCard correctOptionButton = Instantiate(PrefabManager.instance.GetPrefabByName("OptionCard"), this.optionContainer).GetComponent <OptionCard>();
                correctOptionButton.SetOptionCardQuestion(targetQuestionData.rightAnswer, true);

                this.optionButtonList.Add(correctOptionButton.GetComponent <RectTransform>());
                this.gameObjectButtonList.Add(correctOptionButton);

                correctOptionButton.onButtonPressed += this.AfterOptionIsPressed;
            }
            else
            {
                OptionCard wrongOptionButton = Instantiate(PrefabManager.instance.GetPrefabByName("OptionCard"), this.optionContainer).GetComponent <OptionCard>();
                wrongOptionButton.SetOptionCardQuestion(targetQuestionData.wrongAnswers[wrongAnswerIndex], false);

                this.optionButtonList.Add(wrongOptionButton.GetComponent <RectTransform>());
                this.gameObjectButtonList.Add(wrongOptionButton);

                wrongOptionButton.onButtonPressed += this.AfterOptionIsPressed;
                wrongAnswerIndex++;
            }
        }
    }