Time for action – score!
Because the solution requires two functions that each need to access the lists of win and block opportunities, those lists need to be defined at the top of the code as member variables that any function can access:
var aGrid:GameObject[,]; var gameIsOver:boolean; var moves:int; var aBlockOpportunities:List.<GameObject>; var aWinOpportunities:List.<GameObject>;
This is the combined WinOrBlock
function:
function WinOrBlock():GameObject { aBlockOpportunities = new List.<GameObject>(); aWinOpportunities = new List.<GameObject>(); // Empty out these lists before we start searching. // Check the rows for 2 in a row: CheckFor2InARow([Vector2(0,0), Vector2(1,0), Vector2(2,0)]); CheckFor2InARow([Vector2(0,1), Vector2(1,1), Vector2(2,1)]); CheckFor2InARow([Vector2(0,2), Vector2(1,2), Vector2(2,2)]); // Check the columns for 2 in a row: CheckFor2InARow([Vector2(0,0), Vector2(0,1), Vector2(0,2)]); CheckFor2InARow([Vector2(1...