public class DungeonGenerator extends Object
this class exposes a DungeonUtility member; DungeonUtility also has many useful static methods
,
for the less-precise behavior; at least it's consistent
Modifier and Type | Class and Description |
---|---|
static class |
DungeonGenerator.FillEffect
The effects that can be applied to this dungeon.
|
Modifier and Type | Field and Description |
---|---|
protected char[][] |
dungeon |
EnumMap<DungeonGenerator.FillEffect,Integer> |
fx
The effects that will be applied when generate is called.
|
protected DungeonBoneGen |
gen |
protected int |
height |
protected long |
rebuildSeed |
StatefulRNG |
rng |
protected boolean |
seedFixed |
Coord |
stairsDown |
Coord |
stairsUp |
DungeonUtility |
utility |
protected int |
width |
Constructor and Description |
---|
DungeonGenerator()
Make a DungeonGenerator with a LightRNG using a random seed, height 40, and width 40.
|
DungeonGenerator(DungeonGenerator copying)
Copies all fields from copying and makes a new DungeonGenerator.
|
DungeonGenerator(int width,
int height)
Make a DungeonGenerator with the given height and width; the RNG used for generating a dungeon and
adding features will be a LightRNG using a random seed.
|
DungeonGenerator(int width,
int height,
RNG rng)
Make a DungeonGenerator with the given height, width, and RNG.
|
Modifier and Type | Method and Description |
---|---|
DungeonGenerator |
addBoulders(int percentage)
Turns the given percentage of floor cells not already adjacent to walls into wall cells, represented by '#'.
|
DungeonGenerator |
addDoors(int percentage,
boolean doubleDoors)
Turns the given percentage of viable doorways into doors, represented by '+' for doors that allow travel along
the x-axis and '/' for doors that allow travel along the y-axis.
|
DungeonGenerator |
addGrass(int percentage)
Turns the majority of the given percentage of floor cells into grass cells, represented by '"'.
|
DungeonGenerator |
addTraps(int percentage)
Turns the given percentage of open area floor cells into trap cells, represented by '^'.
|
DungeonGenerator |
addWater(int percentage)
Turns the majority of the given percentage of floor cells into water cells, represented by '~'.
|
DungeonGenerator |
addWater(int percentage,
int islandSpacing)
Turns the majority of the given percentage of floor cells into water cells, represented by '~'.
|
DungeonGenerator |
clearEffects()
Removes any door, water, or trap insertion effects that this DungeonGenerator would put in future dungeons.
|
char[][] |
generate()
Generate a char[][] dungeon using TilesetType.DEFAULT_DUNGEON; this produces a dungeon appropriate for a level
of ruins or a partially constructed dungeon.
|
char[][] |
generate(char[][] baseDungeon)
Generate a char[][] dungeon with extra features given a baseDungeon that has already been generated.
|
char[][] |
generate(TilesetType kind)
Generate a char[][] dungeon given a TilesetType; the comments in that class provide some opinions on what
each TilesetType value could be used for in a game.
|
char[][] |
generateRespectingStairs(char[][] baseDungeon)
Generate a char[][] dungeon with extra features given a baseDungeon that has already been generated, and that
already has staircases represented by greater than and less than signs.
|
char[][] |
getBareDungeon()
Get the most recently generated char[][] dungeon out of this class without any chars other than '#' or '.', for
walls and floors respectively.
|
char[][] |
getDungeon()
Get the most recently generated char[][] dungeon out of this class.
|
int |
getHeight()
Height of the dungeon in cells.
|
long |
getRebuildSeed()
Gets the seed that can be used to rebuild an identical dungeon to the latest one generated (or the seed that
will be used to generate the first dungeon if none has been made yet).
|
int |
getWidth()
Width of the dungeon in cells.
|
protected LinkedHashSet<Coord> |
removeAdjacent(LinkedHashSet<Coord> coll,
Coord pt) |
protected LinkedHashSet<Coord> |
removeAdjacent(LinkedHashSet<Coord> coll,
Coord pt1,
Coord pt2) |
void |
setDungeon(char[][] dungeon)
Change the underlying char[][]; only affects the toString method, and of course getDungeon.
|
String |
toString()
Provides a string representation of the latest generated dungeon.
|
protected LinkedHashSet<Coord> |
viableDoorways(boolean doubleDoors,
char[][] map) |
public EnumMap<DungeonGenerator.FillEffect,Integer> fx
protected DungeonBoneGen gen
public DungeonUtility utility
protected int height
protected int width
public Coord stairsDown
public StatefulRNG rng
protected long rebuildSeed
protected boolean seedFixed
protected char[][] dungeon
public DungeonGenerator()
public DungeonGenerator(int width, int height)
width
- The width of the dungeon in cellsheight
- The height of the dungeon in cellspublic DungeonGenerator(int width, int height, RNG rng)
width
- The width of the dungeon in cellsheight
- The height of the dungeon in cellsrng
- The RNG to use for all purposes in this class; if it is a StatefulRNG, then it will be used as-is,
but if it is not a StatefulRNG, a new StatefulRNG will be used, randomly seeded by this parameterpublic DungeonGenerator(DungeonGenerator copying)
copying
- the DungeonGenerator to copypublic char[][] getDungeon()
public char[][] getBareDungeon()
public void setDungeon(char[][] dungeon)
dungeon
- a char[][], probably produced by an earlier call to this class and then modified.public int getHeight()
public int getWidth()
public DungeonGenerator addWater(int percentage)
percentage
- the percentage of floor cells to fill with waterpublic DungeonGenerator addWater(int percentage, int islandSpacing)
percentage
- the percentage of floor cells to fill with waterislandSpacing
- if greater than 1, islands will be placed randomly this many cells apart.public DungeonGenerator addGrass(int percentage)
percentage
- the percentage of floor cells to fill with grasspublic DungeonGenerator addBoulders(int percentage)
percentage
- the percentage of floor cells not adjacent to walls to fill with boulders.public DungeonGenerator addDoors(int percentage, boolean doubleDoors)
percentage
- the percentage of valid openings to corridors to fill with doors; should be between 10 and
20 if you want doors to appear more than a few times, but not fill every possible opening.doubleDoors
- true if you want two-cell-wide openings to receive a door and a wall; false if only
one-cell-wide openings should receive doors. Usually, this should be true.public DungeonGenerator addTraps(int percentage)
percentage
- the percentage of valid cells to fill with traps; should be no higher than 5 unless
the dungeon floor is meant to be a kill screen or minefield.public DungeonGenerator clearEffects()
protected LinkedHashSet<Coord> removeAdjacent(LinkedHashSet<Coord> coll, Coord pt)
protected LinkedHashSet<Coord> removeAdjacent(LinkedHashSet<Coord> coll, Coord pt1, Coord pt2)
protected LinkedHashSet<Coord> viableDoorways(boolean doubleDoors, char[][] map)
public char[][] generate()
public char[][] generate(TilesetType kind)
kind
- a TilesetType enum value, such as TilesetType.DEFAULT_DUNGEONTilesetType
public char[][] generate(char[][] baseDungeon)
baseDungeon
- a pre-made dungeon consisting of '#' for walls and '.' for floors; may be modified in-placepublic char[][] generateRespectingStairs(char[][] baseDungeon)
baseDungeon
- a pre-made dungeon consisting of '#' for walls and '.' for floors, with stairs already in;
may be modified in-placepublic long getRebuildSeed()
Copyright © 2012–2016. All rights reserved.