public Tile CellContent(Cell cell) { if (WithinBounds(cell)) { return Tiles[cell.X][cell.Y]; } return null; }
public bool WithinBounds(Cell cell) { return cell.X >= 0 && cell.X < size && cell.Y >= 0 && cell.Y < size; }
public bool CellAvailable(Cell cell) { return !CellOccupied(cell); }
bool CellOccupied(Cell cell) { return CellContent(cell) != null; }
public void MoveTile(Tile tile, Cell cell) { if (!tile.PositionsEqual(cell)) { cells[tile.X][tile.Y] = null; cells[cell.X][cell.Y] = tile; tile.UpdatePosition(cell); } }
public bool PositionsEqual(Cell cell) { return cell.X == this.X && cell.Y == this.Y; }
public void SavePosition() { previousPosition = new Cell { X = X, Y = Y }; }
public void UpdatePosition(Cell cell) { X = cell.X; Y = cell.Y; OnPositionUpdated(EventArgs.Empty); }
public Tile(Cell cell, int value = 2) { X = cell.X; Y = cell.Y; this.value = value; }