public void ValidateAnswer()
    {
        string answer = _passcodeMenu.transform.Find("TxtPasscode").GetComponent <InputField>().text;

        int  intAnswer = 0;
        bool isValid   = int.TryParse(answer, out intAnswer);

        if (_doorInstance != null)
        {
            if (intAnswer == _doorInstance._randInteger && isValid)
            {
                _doorInstance._isSolved = true;
                _isPaused = false;
                _passcodeMenu.SetActive(false);
                _doorInstance.Open();
                _doorInstance = null;
            }
            else
            {
                _passcodeMenu.SetActive(false);
                GenericPause("Wrong answer");
            }
        }
        else if (_fragmentInstance != null)
        {
            int result = Convert.ToInt32(NumeralConverter.ConvertRomanToDecimal(answer));
            if (result == _fragmentInstance._passcode)
            {
                _passcodeMenu.SetActive(false);
                StringBuilder sb = new StringBuilder();
                foreach (char numeral in _fragmentInstance._numerals)
                {
                    sb.Append(numeral);
                }

                string numeralResult = sb.ToString();
                _txtRomanNumeralData.GetComponent <Text>().text += sb.ToString();
                Destroy(_fragmentInstance.gameObject);
                _fragmentInstance = null;
                GenericPause("You found some Numerals in a memory fragment. Maybe this is a clue to get to the core? \r\n" + numeralResult);
            }
            else
            {
                _passcodeMenu.SetActive(false);
                GenericPause("Wrong answer");
            }
        }
        _passcodeMenu.transform.Find("TxtPasscode").GetComponent <InputField>().text = "";
    }
Ejemplo n.º 2
0
    void MakePasscode()
    {
        List <char>   numerals = _previousFragment.GetComponent <NumeralFragmentController>()._numerals;
        StringBuilder sb       = new StringBuilder();

        foreach (char numeral in numerals)
        {
            sb.Append(numeral);
        }

        string result        = sb.ToString();
        string decimalResult = NumeralConverter.ConvertRomanToDecimal(result);

        _passcode = Convert.ToInt32(decimalResult);
    }