private int ColumnOrRow() { // make a copy of the current matches List <GameObject> matchCopy = findMatches.currentMaches as List <GameObject>; // cycle through all of match copy and decide if a bomb need to be made for (int i = 0; i < matchCopy.Count; i++) { //store this dot Dot thisDot = matchCopy[i].GetComponent <Dot>(); int column = thisDot.column; int row = thisDot.row; int columMatch = 0; int rowMatch = 0; // cycle through the rest of the pieces and compare for (int j = 0; j < matchCopy.Count; j++) { // store the next dot Dot nextDot = matchCopy[j].GetComponent <Dot>(); if (nextDot == thisDot) { continue; } if (nextDot.column == thisDot.column && nextDot.CompareTag(thisDot.tag)) { columMatch++; } if (nextDot.row == thisDot.row && nextDot.CompareTag(thisDot.tag)) { rowMatch++; } } // return 3 if column or row match // return 2 if adjacent // return 1 if it's a color bomb if (columMatch == 4 || rowMatch == 4) { return(1); } if (columMatch == 2 && rowMatch == 2) { return(2); } if (columMatch == 3 || rowMatch == 3) { return(3); } } return(0); }
private int ColumnOrRow() { List <GameObject> matchCopy = findMatches.currentMatches as List <GameObject>; for (int i = 0; i < matchCopy.Count; i++) { Dot thisDot = matchCopy[i].GetComponent <Dot>(); int column = thisDot.column; int row = thisDot.row; int columnMatch = 0; int rowMatch = 0; for (int j = 0; j < matchCopy.Count; j++) { Dot nextDot = matchCopy[j].GetComponent <Dot>(); if (nextDot == thisDot) { continue; } if (nextDot.column == thisDot.column && nextDot.CompareTag(thisDot.tag)) { columnMatch++; } if (nextDot.row == thisDot.row && nextDot.CompareTag(thisDot.tag)) { rowMatch++; } } // return 1 if colorbomb // return 2 if adjacent // return 3 if column or row match if (columnMatch == 4 || rowMatch == 4) { return(1); } if (columnMatch == 2 && rowMatch == 2) { return(2); } if (columnMatch == 3 || rowMatch == 3) { return(3); } } return(0); }