void SelectAnswer(GameObject button, bool isCorrect)
    {
        Image image = button.GetComponent <Image>();
        Text  text  = button.GetComponentInChildren <Text>();

        // Disable all buttons after answer is selected
        GameObject[] buttonObjects = GameObject.FindGameObjectsWithTag("UserInput");
        foreach (GameObject _button in buttonObjects)
        {
            _button.GetComponent <Button>().interactable = false;
        }

        // Show question
        answerButton.SetActive(true);

        if (isCorrect)
        {
            image.color = Scheme.Green;
            _gameShow.CorrectAnswer();
        }
        else
        {
            image.color = Scheme.Red;
            _gameShow.WrongAnswer();
        }
        text.color = Color.white;
    }
    void SubmitGuess(InputField input)
    {
        if (input.text != "")
        {
            input.interactable = false;

            if (input.text.ToLower() == _current.blank.ToLower())
            {
                _gameShow.CorrectAnswer();
            }
            else
            {
                answer.SetActive(true);
                int    underscores = _current.question.Count(f => f == '_');
                string _replace    = "";

                for (int i = 0; i < underscores; i++)
                {
                    _replace += "_";
                }

                string solution = _current.question.Replace(_replace, "<i>" + _current.blank + "</i>");
                answer.GetComponent <Text>().DOText(solution, 1f);
                _gameShow.WrongAnswer();
            }
        }
    }
示例#3
0
    void SubmitGuess(InputField input)
    {
        if (input.text != "")
        {
            input.interactable = false;

            if (input.text.ToLower() == _current.word.ToLower())
            {
                _gameShow.CorrectAnswer();
            }
            else
            {
                answer.SetActive(true);
                answer.GetComponent <Text>().DOText("The  answer was: " + _current.word, 1f);
                _gameShow.WrongAnswer();
            }
        }
    }
    void SelectAnswer(bool answer)
    {
        // Disable all buttons after answer is selected
        GameObject[] buttonObjects = GameObject.FindGameObjectsWithTag("UserInput");
        foreach (GameObject _button in buttonObjects)
        {
            _button.GetComponent <Button>().interactable = false;
        }

        if (answer && _current.isTrue)
        {
            _gameShow.CorrectAnswer();
        }
        else if (!answer && !_current.isTrue)
        {
            _gameShow.CorrectAnswer();
        }
        else
        {
            _gameShow.WrongAnswer();
        }
    }