示例#1
0
        private void PieceToBoardBlocks(PieceBase piece)
        {
            var bounding = piece.BoundingArea;
            IList <List <bool> > result = piece.DecomposeCollisionMapInLinesOfBlocks();

            for (int y = 0; y < bounding.Height; y++)
            {
                for (int x = 0; x < bounding.Width; x++)
                {
                    if (bounding.Y + y > 0 && bounding.Y + y < _boardLines.Count)
                    {
                        _boardLines[bounding.Y + y].Positions[bounding.X + x] = result[y][x];
                    }
                }
            }
        }
示例#2
0
        private static bool FigurePieceBlockCollsion(PieceBase piece, IList <List <bool> > currBoardPieceCollision)
        {
            var  pieceBlockLines = piece.DecomposeCollisionMapInLinesOfBlocks();
            bool isCollision     = false;
            int  countY          = 0;

            while (countY < pieceBlockLines.Count && !isCollision)
            {
                int max    = pieceBlockLines[countY].Count;
                int countX = 0;
                while (countX < max && !isCollision)
                {
                    var pieceResult    = pieceBlockLines[countY][countX];
                    var boarLineResult = currBoardPieceCollision[countY][countX];
                    isCollision = (pieceResult && boarLineResult);
                    countX++;
                }
                countY++;
            }

            return(isCollision);
        }