Exemplo n.º 1
0
    private void HandleKeyboardInput()
    {
        if (_activePlatform == null)
        {
            _activePlatform = platformGenerator.GetNextPlatform();
        }

        string userInput = Input.inputString;

        if (userInput.Length == 0)
        {
            return;
        }

        bool isLetterCorrect = userInput[0] == _activePlatform.Word[_currentletterIndex];

        if (!isLetterCorrect)
        {
            int remainingHealthPoints = healthScript.RemoveHealthPoint();

            if (remainingHealthPoints == 0)
            {
                _isGameOver = true;
                gameOverMenu.SetActive(true);
                return;
            }
            _incorrectLetterCount++;
        }

        _activePlatform.HighlightLetterText(_currentletterIndex, isLetterCorrect);

        _currentletterIndex++;

        if (_currentletterIndex == _activePlatform.Word.Length)
        {
            PlatformCompleted();

            if (_activePlatform == null)
            {
                _isGameOver = true;
                gameOverMenu.SetActive(true);
            }
        }
    }