private bool ColorRandomWhiteCube(int row) { // If the row is already full, return false if (numWhiteCubes[row] == 0) { return(false); } int col = -1; // we know there's at least one valid location while (col < 0) { // try a random column col = Random.Range(0, gridWidth); // if it's not white (0 is white) if (cubes[col, row].GetColorIndex() > 0) { // then reset column to -1 and keep trying col = -1; } } // set the chosen cube to the color of the next cube cubes[col, row].SetColor(nextCube.GetColorIndex(), cubeColors[nextCube.GetColorIndex()]); // update the white cube count numWhiteCubes[row]--; return(true); }