Beispiel #1
0
        public DungeonDisplayer(Dungeon dungeon)
        {
            InitializeComponent();

            if (dungeon == null) {
                throw new NullReferenceException("Invalid argument for DungeonDisplayer");
            }
            this.dungeon = dungeon;

            this.ClientSize = new Size(800, 600);
        }
Beispiel #2
0
        public static int[, ] ExpandToTiles(Dungeon dungeon)
        {
            // Instantiate our tile array
            int[, ] tiles = new int[dungeon.Width * 2 + 1, dungeon.Height * 2 + 1];

            // Initialize the tile array to rock
            for (int x = 0; x < dungeon.Width * 2 + 1; x++)
            {
                for (int y = 0; y < dungeon.Height * 2 + 1; y++)
                {
                    tiles[x, y] = (int)TileType.Rock;
                }
            }

            // Fill tiles with corridor values for each room in dungeon
            foreach (Room room in dungeon.Rooms)
            {
                // Get the room min and max location in tile coordinates
                Point minPoint = new Point(room.Bounds.Location.X * 2 + 1, room.Bounds.Location.Y * 2 + 1);
                Point maxPoint = new Point(room.Bounds.Right * 2, room.Bounds.Bottom * 2);

                // Fill the room in tile space with an empty value
                for (int i = minPoint.X; i < maxPoint.X; i++)
                {
                    for (int j = minPoint.Y; j < maxPoint.Y; j++)
                    {
                        tiles[i, j] = (int)TileType.Empty;
                    }
                }
            }

            // Loop for each corridor cell and expand it
            foreach (Point cellLocation in dungeon.CorridorCellLocations)
            {
                Point tileLocation = new Point(cellLocation.X * 2 + 1, cellLocation.Y * 2 + 1);
                tiles[tileLocation.X, tileLocation.Y] = (int)TileType.Empty;

                if (dungeon[cellLocation].NorthSide == SideType.Empty)
                {
                    tiles[tileLocation.X, tileLocation.Y - 1] = (int)TileType.Empty;
                }
                if (dungeon[cellLocation].NorthSide == SideType.Door)
                {
                    tiles[tileLocation.X, tileLocation.Y - 1] = (int)TileType.Door;
                }

                if (dungeon[cellLocation].SouthSide == SideType.Empty)
                {
                    tiles[tileLocation.X, tileLocation.Y + 1] = (int)TileType.Empty;
                }
                if (dungeon[cellLocation].SouthSide == SideType.Door)
                {
                    tiles[tileLocation.X, tileLocation.Y + 1] = (int)TileType.Door;
                }

                if (dungeon[cellLocation].WestSide == SideType.Empty)
                {
                    tiles[tileLocation.X - 1, tileLocation.Y] = (int)TileType.Empty;
                }
                if (dungeon[cellLocation].WestSide == SideType.Door)
                {
                    tiles[tileLocation.X - 1, tileLocation.Y] = (int)TileType.Door;
                }

                if (dungeon[cellLocation].EastSide == SideType.Empty)
                {
                    tiles[tileLocation.X + 1, tileLocation.Y] = (int)TileType.Empty;
                }
                if (dungeon[cellLocation].EastSide == SideType.Door)
                {
                    tiles[tileLocation.X + 1, tileLocation.Y] = (int)TileType.Door;
                }
            }

            return(tiles);
        }