// Decrease the difficulty based on the number of errors public IEnumerator AdaptDifficulty(int numErrors, GameObject letter) { // Disable Keyboard //keyboardIsEnabled = false; // Destroy the incorrect letter yield return(new WaitForSeconds(0.2f)); Destroy(letter); // If 3 or fewer errors, start the WaitForHint Coroutine based on the number of errors if (numErrors < 4) { StartCoroutine(WaitForHint(numErrors)); } // If the number of user errors are 4 or higher, disable the keyboard until the correct letter is pressed if (numErrors >= 4) { // Loop the animation and disable all keys except the correct one isAnimationLooping = true; keyboardIsEnabled = false; helper.DisableAllKeys(); helper.EnableKeyboardButton(slots.GetChild(helper.currentSlotIndex).name.ToString().ToLower()); yield return(new WaitUntil(() => slots.GetChild(helper.currentSlotIndex).name.ToString().ToLower() == key.ToString().ToLower())); // After the user solves the correct letter, enable the keyboard and disable the hint loop helper.EnableAllKeys(); keyboardIsEnabled = true; isAnimationLooping = false; // Get the correct letter OnKeyPressed(key); } // Re-enable the keyboard keyboardIsEnabled = true; }