private static void addEntranceAndExit(Level level, Rect dungeon) { Location loc = new Location(0, 0); while (!isStairCandidate(level, loc)) { loc.x = Util.random.Next(dungeon.x1, dungeon.x2); loc.y = Util.random.Next(dungeon.y1, dungeon.y2); } Staircase upcase = new Staircase(true); level.addWalkable(upcase, loc); level.upStairs = loc; loc = new Location(0, 0); while (!isStairCandidate(level, loc)) { loc.x = Util.random.Next(dungeon.x1, dungeon.x2); loc.y = Util.random.Next(dungeon.y1, dungeon.y2); } Staircase downcase = new Staircase(false); level.addWalkable(downcase, loc); level.downStairs = loc; }
private static void tryAddFeature(Level level, Location doorLoc, Feature feature) { Direction[] directions = { Direction.North, Direction.South, Direction.West, Direction.East }; foreach (Direction direction in directions) { Rect rect = createRect(doorLoc, direction, feature); rect.expand(); if (rectIsClear(level, rect)) { rect.compress(); if (feature == Feature.Room) { carveRoom(level, rect, false, TileType.Dungeon_Floor); } else if (feature == Feature.Corridor) { carveCorridor(level, rect, false, TileType.Dungeon_Floor); } level.addTile(new Tile(false, TileType.Dungeon_Floor), doorLoc); level.addWalkable(new Door(), doorLoc); break; } } }
private static void addChests(Level level, Rect bounds) { const int numChests = 5; for (int i = 0; i < numChests; i++) { Location chestLoc = new Location(0, 0); while (!isChestCandidate(level, chestLoc)) { chestLoc.x = Util.random.Next(bounds.x1, bounds.x2); chestLoc.y = Util.random.Next(bounds.y1, bounds.y2); } Chest chest = new Chest(); level.addWalkable(chest, chestLoc); } }