Пример #1
0
Файл: Board.cs Проект: 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();
    
 }
Пример #2
0
Файл: Cell.cs Проект: bdr27/c-
 public Cell()
 {
     topLeft = topRight = bottomLeft = bottomRight = null;
 }
Пример #3
0
Файл: Board.cs Проект: 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;

        }