Zombies and the Typer class

We've now configured the zombie to display the selected word, and also to add text stylizations based on player input. However, we still haven't linked player input through the Typer class (coded in the last chapter) with the zombie NPC. Let's do this now by adding a new function to the EnemyAI class, namely UpdateTypedWord. This function compares the typed word with the associated word to determine the extent of a match. The purpose is twofold--firstly, to generate the MatchedWord string and highlight the typed portion of the AssocWord, and secondly, to fire a word matched event (OnTypingMatched), which causes the zombie to die. Consider the following code:

    //------------------------------------  public void ...

Get Mastering Unity 2017 Game Development with C# - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.