private int ScanForCombos(int x, int y, bool checkRow) { // Setup variables int startIndex = y, maxIndex = grid.Height; if (checkRow == true) { startIndex = x; maxIndex = grid.Width; } // Grab the first block Block compareBlock = grid.Blocks[x, y]; // Before check anything, increment the end index on unit past the start int endIndex = (startIndex + 1); // Check the block if (compareBlock == null) { // Return the end index immediately if this is an empty cell return(endIndex); } else if (LengthOfFormation(x, y, startIndex, ref endIndex, maxIndex, compareBlock, checkRow) >= BlocksInARow) { // At this point, we found a row. Look for a pre-existing hashset. Block[] newFormation = CreateNewFormation(x, y, startIndex, endIndex, checkRow); // Add this formation in the appropriate list ScannedFormations.AddFormation(newFormation, checkRow); } return(endIndex); }
private DiscoveredFormations ScanFormations(int numCombos, out bool isFormationFound) { // Clear the list ScannedFormations.Reset(); // Drop the blocks, first AnimateBlocksDropping(); // Scan the grid for any formations ScanRowsForCombos(numCombos); ScanColumnsForCombos(numCombos); // Check how many formations were found isFormationFound = ScannedFormations.IsFormationFound; return(ScannedFormations); }