C# Class Gruppe22.Backend.Map

Backend object representing a room in the game
Inheritance: IHandleEvent, IDisposable
Exibir arquivo Open project: propra13-orga/gruppe22 Class Usage Examples

Protected Properties

Property Type Description
_actors List
_dungeonname string
_exits List
_floorFile string
_height int
_id int
_level int
_light int
_music string
_name string
_tiles List>
_updateTiles HashSet
_wallFile string
_width int

Public Methods

Method Description
AssignPlayer ( string GUID = "" ) : int

Method to add the player character in the current map(room)

CanMove ( Coords currentPos, Direction dir ) : bool

Check whether it is possible to move from a certain place on a map in a certain direction

ClearActors ( ) : void
ClosestEnemy ( Coords coords, int radius = 4, bool includePlayer = true, bool includeNPC = true, bool includeEnemy = true ) : Backend.Coords

Get coordinates for closest enemy within a specified radius

DirectionTile ( Coords start, Direction dir ) : Backend.Coords

Get coordinates for next tile in a certain direction

Dispose ( ) : void

Clean up: Remove all List objects manually (avoid garbage collection)

ExitToEntry ( int ToRoom, List exits ) : List

Switch Entrance and Exit in a list of exit-objects (for corresponding rooms)

FromXML ( string input, Backend targetCoords = null, bool resetPlayer = false ) : void

GetCheckpointCoords ( ) : Backend.Coords

Get coordinates of checkpoint on map (if any)

HandleEvent ( bool DownStream, Events eventID ) : void

Event Handling (implementation of IHandleEvent)

Load ( string filename, Backend targetCoords = null, bool resetPlayer = false, string subdir = "save\\auto\\" ) : void

Map ( ) : System

Basic constructor (creating an empty map)

Map ( IHandleEvent parent, string filename = "", Backend playerPos = null ) : System

Constructor for a loading a map from a file

MoveActor ( Actor actor, Direction dir ) : void

Move an actor on the map in a specified direction (does not check for walls - use CanMove)

NextDirection ( Direction dir, bool directOnly = false ) : Direction

Turns around clockwise (i.e. Up->Right->Down->Left->Up)

OppositeDirection ( Direction dir ) : Direction

Find the exact opposite facing of a direction

PathTo ( Coords from, Backend to, List &result, HashSet &visited, int maxlength = 20 ) : void

Find a path between two tiles (not necessarily only or shortest route!)

PositionActor ( Actor actor, Coords coords ) : void

Move an actor on the map in a specified direction (does not check for walls - use CanMove)

ReadXML ( XmlReader xmlr, Backend targetCoords = null, bool resetPlayer = false ) : void

Load a map from a file

Save ( string filename, string subdir = "save\\auto\\" ) : void

Write the current map to a file

TileByCoords ( Coords coords ) : FloorTile

Get tile specified by a coords-object (deprecated, use direct access by map[])

ToString ( ) : string

Display map & walls in text form

ToXML ( ) : string

Get the current Map as an XML-String

Uncover ( Coords coords, int radius = 4 ) : void

Make a square-shaped area of a specified radius visible on minimap

Update ( GameTime gameTime ) : void

Refresh tiles which do something (traps, enemies, NPCs)

WhichWayIs ( Coords from, Backend to, bool DirectOnly = false ) : Direction

Determine which way one square is from another

firstActorID ( int x, int y ) : int

Get ID of first actor on a specified tile

this ( Coords coords ) : FloorTile

Get the tile at coordinates specified by a coords-object

this ( int x, int y ) : FloorTile

Get the tile at coordinates x and y

Method Details

AssignPlayer() public method

Method to add the player character in the current map(room)
public AssignPlayer ( string GUID = "" ) : int
GUID string
return int

CanMove() public method

Check whether it is possible to move from a certain place on a map in a certain direction
public CanMove ( Coords currentPos, Direction dir ) : bool
currentPos Coords Coordinates on current map
dir Direction Direction to move to
return bool

ClearActors() public method

public ClearActors ( ) : void
return void

ClosestEnemy() public method

Get coordinates for closest enemy within a specified radius
public ClosestEnemy ( Coords coords, int radius = 4, bool includePlayer = true, bool includeNPC = true, bool includeEnemy = true ) : Backend.Coords
coords Coords Center point to start checking from
radius int Number of squares to move up/left/right/down
includePlayer bool true if player should be an "enemy"
includeNPC bool true if NPCs should be "enemies"
includeEnemy bool true if monsters should be "enemies"
return Backend.Coords

DirectionTile() public static method

Get coordinates for next tile in a certain direction
public static DirectionTile ( Coords start, Direction dir ) : Backend.Coords
start Coords Current tile
dir Direction Direction to look at
return Backend.Coords

Dispose() public method

Clean up: Remove all List objects manually (avoid garbage collection)
public Dispose ( ) : void
return void

ExitToEntry() public static method

Switch Entrance and Exit in a list of exit-objects (for corresponding rooms)
public static ExitToEntry ( int ToRoom, List exits ) : List
ToRoom int Which room to switch
exits List List of exits
return List

FromXML() public method

public FromXML ( string input, Backend targetCoords = null, bool resetPlayer = false ) : void
input string
targetCoords Backend
resetPlayer bool
return void

GetCheckpointCoords() public method

Get coordinates of checkpoint on map (if any)
public GetCheckpointCoords ( ) : Backend.Coords
return Backend.Coords

HandleEvent() public method

Event Handling (implementation of IHandleEvent)
public HandleEvent ( bool DownStream, Events eventID ) : void
DownStream bool true if message is meant for children; false if it is meant for parents
eventID Events Unique ID of the event
return void

Load() public method

public Load ( string filename, Backend targetCoords = null, bool resetPlayer = false, string subdir = "save\\auto\\" ) : void
filename string
targetCoords Backend
resetPlayer bool
subdir string
return void

Map() public method

Basic constructor (creating an empty map)
public Map ( ) : System
return System

Map() public method

Constructor for a loading a map from a file
public Map ( IHandleEvent parent, string filename = "", Backend playerPos = null ) : System
parent IHandleEvent An event handler to pass events to
filename string Filename of XML-file containing map data
playerPos Backend Coordinates of player on map
return System

MoveActor() public method

Move an actor on the map in a specified direction (does not check for walls - use CanMove)
public MoveActor ( Actor actor, Direction dir ) : void
actor Actor The actor object to move
dir Direction Direction to move to
return void

NextDirection() public static method

Turns around clockwise (i.e. Up->Right->Down->Left->Up)
public static NextDirection ( Direction dir, bool directOnly = false ) : Direction
dir Direction Start direction
directOnly bool true if diagonals should not be allowed
return Direction

OppositeDirection() public static method

Find the exact opposite facing of a direction
public static OppositeDirection ( Direction dir ) : Direction
dir Direction Direction to start
return Direction

PathTo() public method

Find a path between two tiles (not necessarily only or shortest route!)
public PathTo ( Coords from, Backend to, List &result, HashSet &visited, int maxlength = 20 ) : void
from Coords Tile to start from
to Backend Tile to move to
result List List to put result path into
visited HashSet TIles visited on current path (avoid circles)
maxlength int Maximum length of path
return void

PositionActor() public method

Move an actor on the map in a specified direction (does not check for walls - use CanMove)
public PositionActor ( Actor actor, Coords coords ) : void
actor Actor The actor object to move
coords Coords
return void

ReadXML() public method

Load a map from a file
public ReadXML ( XmlReader xmlr, Backend targetCoords = null, bool resetPlayer = false ) : void
xmlr System.Xml.XmlReader
targetCoords Backend
resetPlayer bool
return void

Save() public method

Write the current map to a file
public Save ( string filename, string subdir = "save\\auto\\" ) : void
filename string The filename to write to
subdir string
return void

TileByCoords() public method

Get tile specified by a coords-object (deprecated, use direct access by map[])
public TileByCoords ( Coords coords ) : FloorTile
coords Coords Coordinates of tile
return FloorTile

ToString() public method

Display map & walls in text form
public ToString ( ) : string
return string

ToXML() public method

Get the current Map as an XML-String
public ToXML ( ) : string
return string

Uncover() public method

Make a square-shaped area of a specified radius visible on minimap
public Uncover ( Coords coords, int radius = 4 ) : void
coords Coords Center point
radius int steps to move up/left/right/down
return void

Update() public method

Refresh tiles which do something (traps, enemies, NPCs)
public Update ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime
return void

WhichWayIs() public static method

Determine which way one square is from another
public static WhichWayIs ( Coords from, Backend to, bool DirectOnly = false ) : Direction
from Coords Source square
to Backend Target Square
DirectOnly bool false (default) if diagonals are allowed
return Direction

firstActorID() public method

Get ID of first actor on a specified tile
public firstActorID ( int x, int y ) : int
x int x-coordinates of tile
y int y-coordinates of tile
return int

this() public method

Get the tile at coordinates specified by a coords-object
public this ( Coords coords ) : FloorTile
coords Coords Coordinate object specifying the tile
return FloorTile

this() public method

Get the tile at coordinates x and y
public this ( int x, int y ) : FloorTile
x int The x-coordinate
y int The y-coordinate
return FloorTile

Property Details

_actors protected_oe property

A list of Actors in the current room
protected List _actors
return List

_dungeonname protected_oe property

Descriptive name of current dungeon
protected string _dungeonname
return string

_exits protected_oe property

A list of all exits from current room
protected List _exits
return List

_floorFile protected_oe property

XML-File containing floor used in dungeon
protected string _floorFile
return string

_height protected_oe property

Internal current height
protected int _height
return int

_id protected_oe property

A unique ID-number for current room
protected int _id
return int

_level protected_oe property

Level of current map (used to determine difficulty etc.)
protected int _level
return int

_light protected_oe property

Ambient light in dungeon (higher value means increased radius)
protected int _light
return int

_music protected_oe property

Reference to music used in room
protected string _music
return string

_name protected_oe property

Descriptive name of current map
protected string _name
return string

_tiles protected_oe property

A two dimensional list of tiles
protected List> _tiles
return List>

_updateTiles protected_oe property

A list of tiles to update each cycle (save ressources)
protected HashSet _updateTiles
return HashSet

_wallFile protected_oe property

XML-File containing tileset used in dungeon
protected string _wallFile
return string

_width protected_oe property

Internal current width
protected int _width
return int