public bool RemoveCurrentLetter(char letter) { if (GetCurrentLetter() != letter) { isWordWrittenWithError = true; OnTypeLetterFailed?.Invoke(); return(false); } MoveToNextLetter(); OnTypeLetterSuccess?.Invoke(); if (IsTyped()) { OnCompleteTypingWord?.Invoke(); if (isWordWrittenWithError) { OnWrittenWordWithErrors?.Invoke(); } else { OnWrittenWordWithoutErrors?.Invoke(); } return(true); } OnTypeLetterUpdateReturnUnwrittenPart?.Invoke(GetUnwrittenPartOfWord()); OnTypeLetterUpdateReturnWrittenPart?.Invoke(GetWrittenPartOfWord()); return(true); }
public void ProcessInput(char input) { if (activeWord != null) { if (activeWord.RemoveCurrentLetter(input)) { DebugLogOfRemovedLetter(input); } return; } var word = words.FirstOrDefault(w => w.GetCurrentLetter() == input); if (word == null) { OnTypeLetterFailed?.Invoke(); Debug.Log($"Letter [{input}] was not found from words list!"); return; } activeWord = word; activeWord.RemoveCurrentLetter(input); DebugLogOfRemovedLetter(input); }