Ejemplo n.º 1
0
        private bool IsBlockRotatable()
        {
            int[] possiblePoints = currBlock.GetCoordinatesAfterRotation((currBlock.Rotation + 1) % 4);
            int[,] tempBoard = new int[this.board.BoardMatrix.GetLength(0), this.board.BoardMatrix.GetLength(1)];
            for (int i = 0; i < tempBoard.GetLength(0); i++)
            {
                for (int j = 0; j < tempBoard.GetLength(1); j++)
                {
                    tempBoard[i, j] = this.board.BoardMatrix[i, j];
                }
            }

            for (int i = 0; i < currBlock.Coordinates.Length; i += 2)
            {
                tempBoard[currBlock.Coordinates[i], currBlock.Coordinates[i + 1]] = 0;
            }

            for (int i = 0; i < possiblePoints.Length; i += 2)
            {
                if (possiblePoints[i] < 0 || possiblePoints[i] >= Board.Rows)
                {
                    return(false);
                }

                if (possiblePoints[i + 1] < 0 || possiblePoints[i + 1] >= Board.Cols)
                {
                    return(false);
                }

                if (tempBoard[possiblePoints[i], possiblePoints[i + 1]] > 0)
                {
                    return(false);
                }
            }

            return(true);
        }