示例#1
0
        public Board(Size dimension, BoardBlock defaultBlock)
        {
            this.Size = dimension;
            var tempList = new List<BoardBlock>();
            for (int i = 0; i < dimension.Width; i++)
                for (int j = 0; j < dimension.Height; j++)
                    tempList.Add(defaultBlock);

            content = tempList;
        }
示例#2
0
文件: Map.cs 项目: Hyftar/ZodFortress
        /// <summary>
        /// Instantiates a map container.
        /// </summary>
        /// <param name="width">Width of the map</param>
        /// <param name="height">Height of the map</param>
        /// <param name="depth">Depth of the map (number of layers)</param>
        /// <param name="defaultBlock">The block the map is filled with by default</param>
        public Map(int width, int height, int depth, BoardBlock defaultBlock)
        {
            if (depth < 0)
                throw new ArgumentOutOfRangeException("depth");

            if (depth == 0)
                throw new ArgumentException("depth");

            this.Depth = depth;
            this.layers = Enumerable.Range(0, depth).Select(x => new Board(width, height, defaultBlock)).ToArray();
        }
示例#3
0
 public Board(Point maxSize, BoardBlock defaultBlock)
     : this(new Size(maxSize), defaultBlock)
 {
 }
示例#4
0
 public Board(int width, int height, BoardBlock defaultBlock)
     : this(new Size(width, height), defaultBlock)
 {
 }
示例#5
0
 /// <summary>
 /// Places a square of blocks on the specified board.
 /// </summary>
 /// <param name="board">Board for the the blocks to be placed on</param>
 /// <param name="block">Block used for the square</param>
 /// <param name="startingPoint">Starting point of the square (upper left corner)</param>
 /// <param name="sideLength">Length of each side</param>
 public void PlaceSquare(Board board, BoardBlock block, Point startingPoint, int sideLength)
 {
     PlaceSquare(board, block, startingPoint.X, startingPoint.Y, sideLength);
 }
示例#6
0
 /// <summary>
 /// Places a square of blocks on the specified board.
 /// </summary>
 /// <param name="board">Board for the blocks to be placed on</param>
 /// <param name="block">Block used for the square</param>
 /// <param name="startingX">Starting X coordinate of the square (upper left corner)</param>
 /// <param name="startingY">Starting Y coordinate of the square (upper left corner)</param>
 /// <param name="sideLength">Length of each side</param>
 public void PlaceSquare(Board board, BoardBlock block, int startingX, int startingY, int sideLength)
 {
     for (int i = 0; i < sideLength; i++)
         for (int j = 0; j < sideLength; j++)
             PlaceBlock(board, block, new Point(startingX + i, startingY + j));
 }
示例#7
0
 /// <summary>
 /// Places a rectangle of blocks around a specified area
 /// </summary>
 /// <param name="board">Board for the blocks to be placed on</param>
 /// <param name="block">Block used for the rectangle</param>
 /// <param name="startingX">Starting X coordinate of the rectangle</param>
 /// <param name="startingY">Starting Y coordinate of the recatangle</param>
 /// <param name="endingX">Ending X coordinate of the rectangle</param>
 /// <param name="endingY">Ending Y coordinate of the rectangle</param>
 public void PlaceRectangle(Board board, BoardBlock block, int startingX, int startingY, int endingX, int endingY)
 {
     PlaceRectangle(board, block, new Point(startingX, startingY), new Point(endingX, endingY));
 }
示例#8
0
        /// <summary>
        /// Places a rectangle of blocks around the specified area
        /// </summary>
        /// <param name="board">Board for the blocks to be placed on</param>
        /// <param name="block">Block used for the rectangle</param>
        /// <param name="startingPoint">Starting point of the rectangle (upper left corner)</param>
        /// <param name="endingPoint">Ending point of the rectangle (lower right corner)</param>
        public void PlaceRectangle(Board board, BoardBlock block, Point startingPoint, Point endingPoint)
        {
            for (int i = 0; i < endingPoint.X - startingPoint.X; ++i)
            {
                PlaceBlock(board, block, startingPoint.X + i, startingPoint.Y);
                PlaceBlock(board, block, startingPoint.X + i, endingPoint.Y);
            }

            for (int i = 0; i < endingPoint.Y - startingPoint.Y + 1; ++i)
            {
                PlaceBlock(board, block, startingPoint.X, startingPoint.Y + i);
                PlaceBlock(board, block, endingPoint.X, startingPoint.Y + i);
            }
        }
示例#9
0
 /// <summary>
 /// Places a house at the specified location (top left corner of the house).
 /// </summary>
 /// <param name="board">Board for the house to be placed on</param>
 /// <param name="wallBlock">Block the walls are made of</param>
 /// <param name="floorBlock">Block the floor is made of</param>
 /// <param name="x">X coordinate where the top left corner of the house will be placed</param>
 /// <param name="y">Y coordinate where the top left corner of the house will be placed</param>
 public void PlaceHouse(Board board, BoardBlock wallBlock, BoardBlock floorBlock, int x, int y)
 {
     PlaceRectangle(board, Grass, new Point(x-1, y-1), new Point(x + 5, y + 5));
     PlaceRectangle(board, Grass, new Point(x - 2, y - 2), new Point(x + 6, y + 6));
     PlaceSquare(board, floorBlock, new Point(x + 1, y + 1), 3);
     PlaceRectangle(board, WoodWall, new Point(x, y), new Point(x + 4, y + 4));
     PlaceBlock(board, floorBlock, x + 2, y);
 }
示例#10
0
 /// <summary>
 /// Places a block at the specified location in the map.
 /// </summary>
 /// <param name="block">Block to be placed</param>
 /// <param name="x">X coordinate of the block</param>
 /// <param name="y">Y coordinate of the block</param>
 public void PlaceBlock(Board board, BoardBlock block, int x, int y)
 {
     PlaceBlock(board, block, new Point(x, y));
 }
示例#11
0
        /// <summary>
        /// Places a block at the specified location in the map.
        /// </summary>
        /// <param name="board"></param>
        /// <param name="block"></param>
        /// <param name="point"></param>
        public void PlaceBlock(Board board, BoardBlock block, Point point)
        {
            if (point.X < 0 || point.X >= board.Size.Width || point.Y < 0 || point.Y >= board.Size.Height)
                return;

            board[point] = block;
        }
示例#12
0
文件: Map.cs 项目: Hyftar/ZodFortress
 /// <summary>
 /// Instantiates a map container.
 /// </summary>
 /// <param name="size">Size of each board</param>
 /// <param name="depth">Depth of the map (number of layers)</param>
 /// <param name="defaultBlock">The block the map is filled with by default</param>
 public Map(Size size, int depth, BoardBlock defaultBlock)
     : this(size.Width, size.Height, depth, defaultBlock)
 {
 }