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 ...

Get Unity 4.x Game Development by Example Beginner's Guide 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.