public bool CanMoveLeft() { //get the min col of the tetromino int minCol = CoveredCells.Min(_ => _.Column); //If any of the covered spaces are currently in the left border, the piece cannot move left. if (minCol == 0) { return(false); } //get all the leftest tetromino's cells var leftestCells = CoveredCells.Where(_ => _.Column == minCol); //For each of the covered spaces, get the space immediately below foreach (var leftestCell in leftestCells) { if (_GameBoard.GetRow(leftestCell.Row).HasCellTaken(leftestCell.Column - 1)) { return(false); } } return(true); }
/// <summary> /// Check whether the tetromino can move down by 1 cell or not /// </summary> /// <returns>true if it can move, false otherwise</returns> public bool CanMoveDown() { //get the min row of the tetromino int minRow = CoveredCells.Min(_ => _.Row); //If any of the covered spaces are currently in the lowest row, the piece cannot move down. Console.WriteLine("CanMoveDown - minRow=" + minRow); if (minRow == 0) { return(false); } //get all the lowest tetromino's cells var lowestCells = CoveredCells.Where(_ => _.Row == minRow); //For each of the covered spaces, get the space immediately below foreach (var lowestCell in lowestCells) { if (_GameBoard.GetRow(lowestCell.Row - 1).HasCellTaken(lowestCell.Column)) { return(false); } } return(true); }