Example #1
0
 public Tile CellContent(Cell cell) {
     if (WithinBounds(cell)) {
         return Tiles[cell.X][cell.Y];
     }
     return null;
 }
Example #2
0
 public bool WithinBounds(Cell cell) {
     return cell.X >= 0 && cell.X < size &&
            cell.Y >= 0 && cell.Y < size;
 }
Example #3
0
 public bool CellAvailable(Cell cell) {
     return !CellOccupied(cell);
 }
Example #4
0
 bool CellOccupied(Cell cell) {
     return CellContent(cell) != null;
 }
Example #5
0
 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);
     }
 }
Example #6
0
 public bool PositionsEqual(Cell cell) {
     return cell.X == this.X &&
            cell.Y == this.Y;
 }
Example #7
0
 public void SavePosition() {
     previousPosition = new Cell { X = X, Y = Y };
 }
Example #8
0
 public void UpdatePosition(Cell cell) {
     X = cell.X;
     Y = cell.Y;
     OnPositionUpdated(EventArgs.Empty);
 }
Example #9
0
 public Tile(Cell cell, int value = 2) {
     X = cell.X;
     Y = cell.Y;
     this.value = value;
 }