Winner is coming

We now have all the information we need to check the Squares, to determine which piece they contain, and to call the match if we find 3-in-a-row. In the GameLogic script, scaffold the mighty hard-fought CheckForWin function:

function CheckForWin(square:GameObject):boolean
{
  
}

Did you notice something different about this function declaration? It's got a big, ugly boolean stuck to the side of its face. (Gee—it should really get that looked at).

This function declares a return type. We've already called numerous functions that have a return value, but this is the first time we've set one up in our own custom code. All it means is that somewhere along the way, this function will spit out a boolean value. In fact, it must spit out a ...

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.