Time for action – the final bug

The last bug in the game is that in the pause between someone winning and the game reloading, players can still click on spaces to place their pieces. Let's add a quick condition check to the top of the ClickSpace function. If the game is won, prevent the rest of the code from executing:

function ClickSquare(square:GameObject)
{
   if(gameIsOver) return;

Push the red return button! Eject! Eject!

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.