Time for action – to catch a competitor
Combine these two separate function calls:
square = Win(); if(square == null) square = Block(); if(square == null) square = CreateTrap(); if(square == null) square = PreventTrap();
into this unified call:
square = Win();
if(square == null) square = Block();
if(square == null) square = PreventOrCreateTrap();
The PreventOrCreateTrap
function is very straightforward:
function PreventOrCreateTrap():GameObject { var aP1Corners:List.<GameObject> = new List.<GameObject>(); // Create an empty list to store X-controlled corners var aP2Corners:List.<GameObject> = new List.<GameObject>(); // Create an empty list to store O-controlled corners var aOpenCorners:List.<GameObject> = new List.<GameObject>();
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.