public bool IsSlotValid(Index2D slot) { if (slot.ColumnIndex < 0 || slot.ColumnIndex > BoardSettings.GetDimension().GetColumnCount()) { return(false); } if (slot.RowIndex < 0 || slot.RowIndex > BoardSettings.GetDimension().GetRowCount()) { return(false); } return(true); }
public bool TryGetSlotFromTile(GameObject tile, out Index2D slot) { var columnCount = BoardSettings.GetDimension().GetColumnCount(); var rowCount = BoardSettings.GetDimension().GetRowCount(); slot = null; for (int rowIndex = 0; rowIndex < rowCount; rowIndex++) { for (int columnIndex = 0; columnIndex < columnCount; columnIndex++) { if (tiles[columnIndex, rowIndex] != tile) { continue; } slot = new Index2D(columnIndex, rowIndex); return(true); } } return(false); }