private bool CheckMatch(EntityQueryBuilder builder, int row, int column, Color color, int previousRow, int previousColumn) { var entities = builder.GetCellEntitiesByColumn(column); entities.Sort(new RowComparer(EntityManager)); var countMatched = 0; for (int i = row + 1; i < Setting.Instance.rowCount; i++) { if (previousRow == i) { break; } if (EntityManager.GetCellByEntity(entities[i]).color == color) { countMatched++; } else { break; } } for (int i = row - 1; i >= 0; i--) { if (previousRow == i) { break; } if (EntityManager.GetCellByEntity(entities[i]).color == color) { countMatched++; } else { break; } } if (countMatched >= 2) { return(true); } entities = builder.GetCellEntitiesByRow(row); entities.Sort(new ColumnComparer(EntityManager)); countMatched = 0; for (int i = column + 1; i < Setting.Instance.columnCount; i++) { if (previousColumn == i) { break; } if (EntityManager.GetCellByEntity(entities[i]).color == color) { countMatched++; } else { break; } } for (int i = column - 1; i >= 0; i--) { if (previousColumn == i) { break; } if (EntityManager.GetCellByEntity(entities[i]).color == color) { countMatched++; } else { break; } } return(countMatched >= 2); }