wyvern.kernel.dungeon
Class AbstractLevelGenerator

java.lang.Object
  extended bywyvern.kernel.dungeon.AbstractLevelGenerator
Direct Known Subclasses:
CaveGenerator, DungeonGenerator, MazeGenerator

public abstract class AbstractLevelGenerator
extends java.lang.Object

Common code for maze, dungeon, and cave generators.

Version:
1.0, Oct 07, 1999
Author:
Steve Yegge

Field Summary
static int DEFAULT_HEIGHT
           
static int DEFAULT_WIDTH
           
protected  java.lang.String floor_
           
protected  int height_
           
protected  java.lang.String oobTerrain_
           
protected  java.lang.String stairsDown_
           
protected  java.lang.String stairsUp_
           
protected  java.lang.String terrain_
           
protected  int width_
           
 
Constructor Summary
AbstractLevelGenerator()
           
 
Method Summary
abstract  GameMap generate(java.lang.Class mapclass)
          Creates and returns a GameMap using the current set of properties for this generator.
 java.lang.String getDefaultTerrain()
           
 java.lang.String getDownstairArchetype()
           
 java.lang.String getFloorArchetype()
           
 int getHeight()
           
 java.lang.String getOOBTerrain()
           
 java.lang.String getUpstairArchetype()
           
 int getWidth()
           
protected  Terrain instantiateFloor()
          Instantiates the current floor archetype.
protected  GameObject instantiateObject(java.lang.String archname)
          Instantiates an archetype by name.
protected  int rand(int num)
          produces a random value between 0 and num
 void setDefaultTerrain(java.lang.String t)
          Sets the default terrain to use for the generated maps.
 void setDownstairArchetype(java.lang.String arch)
          Sets the arch to use for the down-staircase, if any.
 void setFloorArchetype(java.lang.String name)
          Sets the archetype to use for the floor in places that differ from the default terrain, if appropriate.
 void setHeight(int height)
           
 void setOOBTerrain(java.lang.String t)
          Sets the default out-of-bounds terrain to use for the generated maps.
 void setUpstairArchetype(java.lang.String arch)
          Sets the arch to use for the up-staircase, if any.
 void setWidth(int width)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

terrain_

protected java.lang.String terrain_

oobTerrain_

protected java.lang.String oobTerrain_

floor_

protected java.lang.String floor_

stairsUp_

protected java.lang.String stairsUp_

stairsDown_

protected java.lang.String stairsDown_

width_

protected int width_

height_

protected int height_

DEFAULT_WIDTH

public static final int DEFAULT_WIDTH
See Also:
Constant Field Values

DEFAULT_HEIGHT

public static final int DEFAULT_HEIGHT
See Also:
Constant Field Values
Constructor Detail

AbstractLevelGenerator

public AbstractLevelGenerator()
Method Detail

generate

public abstract GameMap generate(java.lang.Class mapclass)
                          throws java.lang.Exception
Creates and returns a GameMap using the current set of properties for this generator.

Parameters:
mapclass - the class to instantiate
Throws:
java.lang.Exception

setDefaultTerrain

public void setDefaultTerrain(java.lang.String t)
Sets the default terrain to use for the generated maps. All subsequent calls to create maps will use this terrain type.

Parameters:
t - the terrain archetype to use, e.g. "terrain/cave_floor"

getDefaultTerrain

public java.lang.String getDefaultTerrain()

setOOBTerrain

public void setOOBTerrain(java.lang.String t)
Sets the default out-of-bounds terrain to use for the generated maps. All subsequent calls to create maps will use this terrain type.

Parameters:
t - the terrain archetype to use, e.g. "terrain/cave_floor"

getOOBTerrain

public java.lang.String getOOBTerrain()

setFloorArchetype

public void setFloorArchetype(java.lang.String name)
Sets the archetype to use for the floor in places that differ from the default terrain, if appropriate.

Parameters:
name - the archetype to use, e.g. "terrain/gray_brick"

getFloorArchetype

public java.lang.String getFloorArchetype()

setWidth

public void setWidth(int width)

getWidth

public int getWidth()

setHeight

public void setHeight(int height)

getHeight

public int getHeight()

setUpstairArchetype

public void setUpstairArchetype(java.lang.String arch)
Sets the arch to use for the up-staircase, if any.

Parameters:
arch - the archetype local path, e.g. "indoor/stairs_upE"

getUpstairArchetype

public java.lang.String getUpstairArchetype()

setDownstairArchetype

public void setDownstairArchetype(java.lang.String arch)
Sets the arch to use for the down-staircase, if any.

Parameters:
arch - the archetype local path, e.g. "indoor/stairs_downE"

getDownstairArchetype

public java.lang.String getDownstairArchetype()

instantiateObject

protected GameObject instantiateObject(java.lang.String archname)
Instantiates an archetype by name.

Parameters:
archname - the archetype to instantiate
Returns:
the instantiated object, or null if unable to instantiate it

instantiateFloor

protected Terrain instantiateFloor()
Instantiates the current floor archetype.


rand

protected int rand(int num)
produces a random value between 0 and num