Time for action – you win. Now what?
We get the right message, but the game doesn't do anything after that. Let's build in a bit of a pause, and then reload the Game Scene after a win occurs.
At the bottom of the ShowWinnerPrompt
function, add these two lines:
yield WaitForSeconds(3); Application.LoadLevel(0);
We pause for 3 seconds so the players can read the "win" message and grasp the full weight of the situation, and then we automatically reload the level for a new game.
The remaining problem with the game is that if we arrive at a stalemate where neither player wins and there are no more moves to make, the game doesn't know it, and prompts the next player to place a piece anyway. The game should somehow be able to figure out when the game is a draw, and react to that situation.
Have a go hero – draw, pardner
Just as you did earlier in the chapter, take a moment to flap your arms like a chicken. Then think about how you would determine that the game is a draw. Compare your solution(s) with...