コード例 #1
0
ファイル: Board.cs プロジェクト: jvrdev/meteor-contest
 public void RemovePiece(Piece piece)
 {
     for (var i = 0; i < TOTAL_CELL_COUNT; i++)
     {
         // Piece objects are unique, so use reference equality
         if (_boardCells[i].Piece == piece)
         {
             _boardCells[i].Piece = null;
         }
     }
 }
コード例 #2
0
ファイル: Board.cs プロジェクト: jvrdev/meteor-contest
 public bool PlacePiece(Piece piece, int boardCellIdx)
 {
     // We will manipulate the piece using its first cell
     return PlacePiece(piece, 0, boardCellIdx);
 }
コード例 #3
0
ファイル: Board.cs プロジェクト: jvrdev/meteor-contest
 private bool PlacePiece(Piece piece, int pieceCellIdx, int boardCellIdx)
 {
     // We're going to process the piece
     piece.ResetProcessed();
     // Get all the boardCells that this piece would occupy
     var occupiedBoardCells = new List<BoardCell>();
     FindOccupiedBoardCells(occupiedBoardCells, piece.GetPieceCell(pieceCellIdx), _boardCells[boardCellIdx]);
     if (occupiedBoardCells.Count != Piece.NUMBER_OF_CELLS)
     {
         // Some cells of the piece don't fall on the board
         return false;
     }
     if (occupiedBoardCells.Any(t => t.Piece != null))
     {
         return false;
     }
     // Occupy the board cells with the piece
     foreach (var t in occupiedBoardCells)
     {
         t.Piece = piece;
     }
     return true; // The piece fits on the board
 }