Ejemplo n.º 1
0
        public void SetNextQuestion()
        {
            for (int i = 0; i < buttons.Count; i++)
            {
                Destroy(buttons[i].gameObject);
            }

            buttons = new List <QuestionSolver>();
            aux++;
            if (aux < gameQuestions.Count)
            {
                actualQuestion = gameQuestions[aux];

                questionText.text = actualQuestion.Text;
                for (int i = 0; i < actualQuestion.GetAnswersLength(); i++)
                {
                    QuestionSolver newSolver = Instantiate(solver_Pref, buttonParent);
                    newSolver.SetText(actualQuestion.GetAnswerText(i));
                    buttons.Add(newSolver);
                    var temp = i;
                    newSolver.AddListener(delegate { actualQuestion.AnswerAction(temp); });
                    newSolver.AddListener(delegate { SetNextQuestion(); });
                }
            }
            else
            {
                buttonParent.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 80, buttonParent.rect.height);
                questionText.text = "";
                QuestionSolver newSolver = Instantiate(solver_Pref, buttonParent);
                newSolver.SetText("Tu Slime es...");
                buttons.Add(newSolver);
                newSolver.AddListener(evn.Invoke);
                StartCoroutine("Fade");
            }
        }
Ejemplo n.º 2
0
        IEnumerator Fade()
        {
            yield return(new WaitForSeconds(3));

            buttons[0].gameObject.SetActive(false);
            QuestionSolver newSolver = Instantiate(solver_Pref, buttonParent);

            newSolver.SetText("Iniciar Juego");
            buttons.Add(newSolver);
        }
Ejemplo n.º 3
0
        // Start is called before the first frame update
        void Start()
        {
            if (questionsAmount > questions.Count)
            {
                questionsAmount = questions.Count;
            }
            //initialization for game questions
            for (int i = 0; i < questionsAmount; i++)
            {
                int value = Random.Range(0, questions.Count);
                gameQuestions.Add(questions[value]);
                erasedQuestions.Add(questions[value]);
                questions.Remove(questions[value]);
            }
            for (int i = 0; i < erasedQuestions.Count; i++)
            {
                questions.Add(erasedQuestions[i]);
            }
            erasedQuestions = new List <Question>();

            /*for (int i = 0; i < gameQuestions.Count; i++)
             * {
             *  Debug.Log(gameQuestions[i]);
             * }*/
            actualQuestion    = gameQuestions[aux];
            questionText.text = actualQuestion.Text;

            for (int i = 0; i < actualQuestion.GetAnswersLength(); i++)
            {
                QuestionSolver newSolver = Instantiate(solver_Pref, buttonParent);
                newSolver.SetText(actualQuestion.GetAnswerText(i));
                buttons.Add(newSolver);
                var temp = i;
                newSolver.AddListener(delegate { actualQuestion.AnswerAction(temp); });
                newSolver.AddListener(delegate { SetNextQuestion(); });
            }
        }