Ejemplo n.º 1
0
 void WrongAnwserResponse(Button btnWrong)
 {
     PopUpText.fillPopUp("Resposta Errada!!!");
     paintButtons(btnWrong);
     sounds.PlayOneShot(wrongAnswerSound);
     PlayerStats.getIstance().healthLoss();
 }
Ejemplo n.º 2
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.tag == "HP")
     {
         sounds.PlayOneShot(healthSound);
         Destroy(collision.gameObject);
         if (PlayerStats.getIstance().getHealthPoints() < 3)
         {
             PlayerStats.getIstance().healthGain();
         }
         else
         {
             PopUpText.fillPopUp("Vida cheia!");
             StartCoroutine(WaitPopUp());
         }
     }
     else if (collision.gameObject.tag == "Points")
     {
         sounds.PlayOneShot(coinSound);
         PlayerStats.getIstance().addPoints();
         Destroy(collision.gameObject);
     }
     else if (collision.gameObject.tag == "EndOfLevel")
     {
         SceneManager.LoadScene(nextScene);
     }
 }
Ejemplo n.º 3
0
    public void DisplayNextQuestion()
    {
        ResetButtonColor();
        RemoveAllButtonListeners();
        cantBeThisValues.Clear();
        helpCalls = 0;

        PopUpText.fillPopUp("");

        if (questions.Count == 0)
        {
            EndQuestions();
            return;
        }

        string question = questions.Dequeue();
        string ans1     = answers1queue.Dequeue();
        string ans2     = answers2queue.Dequeue();
        string ans3     = answers3queue.Dequeue();
        string ans4     = answers4queue.Dequeue();
        int    rightAns = rightAnswerqueue.Dequeue();

        questionText.text = question;
        answer1Text.text  = ans1;
        answer2Text.text  = ans2;
        answer3Text.text  = ans3;
        answer4Text.text  = ans4;

        if (rightAns == 1)
        {
            btn1.onClick.AddListener(RightAnwserResponse);
            btn2.onClick.AddListener(delegate { WrongAnwserResponse(btn2); });
            btn3.onClick.AddListener(delegate { WrongAnwserResponse(btn3); });
            btn4.onClick.AddListener(delegate { WrongAnwserResponse(btn4); });
        }
        else if (rightAns == 2)
        {
            btn1.onClick.AddListener(delegate { WrongAnwserResponse(btn1); });
            btn2.onClick.AddListener(RightAnwserResponse);
            btn3.onClick.AddListener(delegate { WrongAnwserResponse(btn3); });
            btn4.onClick.AddListener(delegate { WrongAnwserResponse(btn4); });
        }
        else if (rightAns == 3)
        {
            btn1.onClick.AddListener(delegate { WrongAnwserResponse(btn1); });
            btn2.onClick.AddListener(delegate { WrongAnwserResponse(btn2); });
            btn3.onClick.AddListener(RightAnwserResponse);
            btn4.onClick.AddListener(delegate { WrongAnwserResponse(btn4); });
        }
        else if (rightAns == 4)
        {
            btn1.onClick.AddListener(delegate { WrongAnwserResponse(btn1); });
            btn2.onClick.AddListener(delegate { WrongAnwserResponse(btn2); });
            btn3.onClick.AddListener(delegate { WrongAnwserResponse(btn3); });
            btn4.onClick.AddListener(RightAnwserResponse);
        }

        ajuda.onClick.AddListener(delegate { HelpButton(rightAns); });
    }
Ejemplo n.º 4
0
    void HelpButton(int rightAns)
    {
        helpCalls++;
        if (helpCalls <= 2)
        {
            if (!cantBeThisValues.Contains(rightAns))
            {
                cantBeThisValues.Add(rightAns);
            }

            if (PlayerStats.getIstance().getPoints() < 100)
            {
                PopUpText.fillPopUp("Pontos insuficientes! São necessários no mínimo 100 pontos para pedir ajuda!");
                StartCoroutine(WaitPopUp());
            }
            else
            {
                PlayerStats.getIstance().usePoints();
                int randomNumber = Random.Range(1, 4);
                while (verifyHelp(randomNumber, cantBeThisValues))
                {
                    randomNumber = Random.Range(1, 4);
                }
                switch (randomNumber)
                {
                case 1:
                    paintButtons(btn1);
                    break;

                case 2:
                    paintButtons(btn2);
                    break;

                case 3:
                    paintButtons(btn3);
                    break;

                case 4:
                    paintButtons(btn4);
                    break;
                }
                cantBeThisValues.Add(randomNumber);
            }
        }
        else if (helpCalls == 20)
        {
            PopUpText.fillPopUp("Você não cansa de apertar esse botão?");
        }
        else
        {
            PopUpText.fillPopUp("Já utilizou todas as ajudas!");
        }
    }
Ejemplo n.º 5
0
    IEnumerator WaitPopUp()
    {
        yield return(new WaitForSeconds(3f));

        PopUpText.fillPopUp("");
    }