Esempio n. 1
0
        /// <summary> Builds the rooms of the dungeon. </summary>
        private void GenerateRooms()
        {
            // This is a curve so that more rooms are built as the level increases.
            int roomCount = (int)Math.Ceiling((8 * Level * Math.Sqrt(Level)) + Engine.rand.Next(5, 9)) / Level;

            LastRegionID = 0;
            for (int i = 0; i < roomCount; ++i)
            {
                List <int> points = new List <int>();
                points.Add((Engine.rand.Next(1, 15) * 2) + 1); // max height of room is 10. std rand limit is 15 but rand is exclusive
                points.Add((Engine.rand.Next(1, 26) * 2) + 1); // max width of room is 10. std rand limit is 26 but rand is exclusive
                points.Add(points[0] + ((Engine.rand.Next(2, 4) * 2) + 1));
                points.Add(points[1] + ((Engine.rand.Next(2, 4) * 2) + 1));
                // Place a room if there's no overlap
                if (!CheckForRoomOverlap(points))
                {
                    LastRegionID++;
                    BuildRoom(points, LastRegionID);
                    RoomPoints.Add(points);
                }
                // Otherwise place it 1/5 of the time even if there is an overlap

                /*else {
                 *  if(Engine.rand.NextDouble() < .05 || i == roomCount - 1) {
                 *      LastRegionID++;
                 *      BuildRoom(points, LastRegionID);
                 *      RoomPoints.Add(points);
                 *  }
                 * }*/
            }
        }
Esempio n. 2
0
        private void GenerateFinal()
        {
            // big room
            int roomY  = Data.GetLength(0) / 4;
            int roomY2 = 3 * Data.GetLength(0) / 4;
            int roomX  = Data.GetLength(1) / 4;
            int roomX2 = 3 * Data.GetLength(1) / 4;

            RoomPoints.Add(new List <int>(new int[] { roomY, roomX, roomY2, roomX2 }));
            for (int y = roomY; y < roomY2; ++y)
            {
                for (int x = roomX; x < roomX2; ++x)
                {
                    Data[y, x] = new RoomFloor(y, x, 0);
                }
            }
            for (int y = roomY - 1; y < roomY2 + 1; ++y)
            {
                for (int x = roomX - 1; x < roomX2 + 1; ++x)
                {
                    if (Data[y, x] == null)
                    {
                        Data[y, x] = new Wall(y, x);
                    }
                }
            }
            int entryY = roomY2;
            int entryX = (roomX + roomX2) / 2;

            Data[entryY, entryX] = new Stair(entryY, entryX, StairType.Up);
            Data[roomY, (roomX + roomX2) / 2].Inventory.AddItem(new Macguffin());
            Program.player.CoordX = entryX;
            Program.player.CoordY = entryY;
        }
Esempio n. 3
0
 public RoomModel()
 {
     modeDict   = new Dictionary <Vector3Int, float>();
     modeList   = new List <Mode>();
     roomPoints = new RoomPoints();
 }