Exemple #1
0
        public void PlacePiece(Piece piece, int atX, int atY, int orientation)
        {
            var placement = new Placement
            {
                Orientation = orientation,
                X = atX,
                Y = atY,
                Piece = piece,
            };
            Placements.Add(placement);

            var orient = piece.Orientations[orientation];
            for (var pieceY = 0; pieceY < orient.Height; pieceY++)
            for (var pieceX = 0; pieceX < orient.Width; pieceX++)
            {
                if (!orient.IsFilledIn[pieceY, pieceX]) continue;

                var boardY = pieceY + atY;
                var boardX = pieceX + atX;

                CellPieces[boardY, boardX] = piece;
            }

            UnplacedPieces.Remove(piece);
        }
Exemple #2
0
        public Board(int width, int height)
        {
            Width = width;
            Height = height;
            CellPieces = new Piece[Width, Height];

            IsOuty = new bool[Width,Height];
            
            Placements = new List<Placement>();
            UnplacedPieces = new List<Piece>();
        }