public override void Populate() { for (int i = 0; i < options.maxRooms; i++) { int w = rnd.Next(options.roomMinSize, options.roomMaxSize); int h = rnd.Next(options.roomMinSize, options.roomMaxSize); int x = rnd.Next(0, options.width - w - 1); int y = rnd.Next(0, options.height - h - 1); RectInt newRoom = new RectInt(x, y, w, h); if (!newRoom.IntersectAny(rooms)) { createRoom(newRoom); Vector2Int newRoomCenter = newRoom.Center(); if (rooms.Count == 0) { map.Player = new Entity(map, '@', Color.white, "Player", newRoomCenter, true); } else { Vector2Int prevRoomCenter = rooms[rooms.Count - 1].Center(); if (rnd.Next(1) == 1) { createHorizontalTunnel(prevRoomCenter.x, newRoomCenter.x, prevRoomCenter.y); createVerticalTunnel(prevRoomCenter.y, newRoomCenter.y, newRoomCenter.x); } else { createVerticalTunnel(prevRoomCenter.y, newRoomCenter.y, prevRoomCenter.x); createHorizontalTunnel(prevRoomCenter.x, newRoomCenter.x, newRoomCenter.y); } } placeEntities(newRoom); rooms.Add(newRoom); } } }