public void TypeLetter(char letter) { if (hasActiveWord) { //Check if letter was next //Remove it from the word if (activeWord.GetNextLetter() == letter) { activeWord.TypeLetter(); } } else { foreach (TopWord word in words) { if (word.GetNextLetter() == letter) { activeWord = word; hasActiveWord = true; word.TypeLetter(); break; } } } if (hasActiveWord && activeWord.WordTyped()) { AddWord(); hasActiveWord = false; words.Remove(activeWord); } }
public void AddWord() { TopWord word = new TopWord(TopWordGenerator.GetRandomWord(), wordSpawner.SpawnWord()); Debug.Log(word.word); words.Add(word); }