Esempio n. 1
0
File: Board.cs Progetto: bdr27/c-
 public Board()
 {
     int nextID = 1;
     cells = new Cell[BOARD_HEIGHT, BOARD_WIDTH];
     for (int i = 0; i < BOARD_HEIGHT; i++)
     {
         for (int j = 0; j < BOARD_WIDTH; j++)
         {
             cells[i, j] = new Cell()
             
             {
                 row = i,
                 col = j,
                 ID = nextID++,
                 piece = Piece.EMPTY
             };
         }
     }
     setupMoveLocations();
    
 }
Esempio n. 2
0
File: Cell.cs Progetto: bdr27/c-
 public Cell()
 {
     topLeft = topRight = bottomLeft = bottomRight = null;
 }
Esempio n. 3
0
File: Board.cs Progetto: bdr27/c-
        private bool moveableCell(Cell start, Cell end)
        {
            List<Cell> movableLocations = new List<Cell>();
            movableLocations.Add(start.bottomLeft);
            movableLocations.Add(start.bottomRight);
            movableLocations.Add(start.topRight);
            movableLocations.Add(start.topLeft);

            foreach (Cell cell in movableLocations)
            {
                try
                {
                    if (cell.Equals(end))
                    {
                        return true;
                    }
                }
                catch (NullReferenceException)
                {
                    Debug.WriteLine("Out of range");
                }
            }            
            return false;

        }