Beispiel #1
0
Datei: Board.cs Projekt: 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();
    
 }
Beispiel #2
0
Datei: Cell.cs Projekt: bdr27/c-
 public Cell()
 {
     topLeft = topRight = bottomLeft = bottomRight = null;
 }
Beispiel #3
0
Datei: Board.cs Projekt: 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;

        }