C# Class Gruppe22.Backend.Map

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

Protected Properties

Свойство 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

Méthodes publiques

Méthode 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 méthode

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

CanMove() public méthode

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
Résultat bool

ClearActors() public méthode

public ClearActors ( ) : void
Résultat void

ClosestEnemy() public méthode

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"
Résultat Backend.Coords

DirectionTile() public static méthode

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
Résultat Backend.Coords

Dispose() public méthode

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

ExitToEntry() public static méthode

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
Résultat List

FromXML() public méthode

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

GetCheckpointCoords() public méthode

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

HandleEvent() public méthode

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
Résultat void

Load() public méthode

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

Map() public méthode

Basic constructor (creating an empty map)
public Map ( ) : System
Résultat System

Map() public méthode

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
Résultat System

MoveActor() public méthode

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
Résultat void

NextDirection() public static méthode

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
Résultat Direction

OppositeDirection() public static méthode

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

PathTo() public méthode

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
Résultat void

PositionActor() public méthode

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
Résultat void

ReadXML() public méthode

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
Résultat void

Save() public méthode

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
Résultat void

TileByCoords() public méthode

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

ToString() public méthode

Display map & walls in text form
public ToString ( ) : string
Résultat string

ToXML() public méthode

Get the current Map as an XML-String
public ToXML ( ) : string
Résultat string

Uncover() public méthode

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
Résultat void

Update() public méthode

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

WhichWayIs() public static méthode

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
Résultat Direction

firstActorID() public méthode

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
Résultat int

this() public méthode

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

this() public méthode

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
Résultat FloorTile

Property Details

_actors protected_oe property

A list of Actors in the current room
protected List _actors
Résultat List

_dungeonname protected_oe property

Descriptive name of current dungeon
protected string _dungeonname
Résultat string

_exits protected_oe property

A list of all exits from current room
protected List _exits
Résultat List

_floorFile protected_oe property

XML-File containing floor used in dungeon
protected string _floorFile
Résultat string

_height protected_oe property

Internal current height
protected int _height
Résultat int

_id protected_oe property

A unique ID-number for current room
protected int _id
Résultat int

_level protected_oe property

Level of current map (used to determine difficulty etc.)
protected int _level
Résultat int

_light protected_oe property

Ambient light in dungeon (higher value means increased radius)
protected int _light
Résultat int

_music protected_oe property

Reference to music used in room
protected string _music
Résultat string

_name protected_oe property

Descriptive name of current map
protected string _name
Résultat string

_tiles protected_oe property

A two dimensional list of tiles
protected List> _tiles
Résultat List>

_updateTiles protected_oe property

A list of tiles to update each cycle (save ressources)
protected HashSet _updateTiles
Résultat HashSet

_wallFile protected_oe property

XML-File containing tileset used in dungeon
protected string _wallFile
Résultat string

_width protected_oe property

Internal current width
protected int _width
Résultat int