C# Класс Gruppe22.Backend.Map

Backend object representing a room in the game
Наследование: IHandleEvent, IDisposable
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
_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

Открытые методы

Метод Описание
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

Описание методов

AssignPlayer() публичный метод

Method to add the player character in the current map(room)
public AssignPlayer ( string GUID = "" ) : int
GUID string
Результат int

CanMove() публичный метод

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
Результат bool

ClearActors() публичный метод

public ClearActors ( ) : void
Результат void

ClosestEnemy() публичный метод

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"
Результат Backend.Coords

DirectionTile() публичный статический метод

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
Результат Backend.Coords

Dispose() публичный метод

Clean up: Remove all List objects manually (avoid garbage collection)
public Dispose ( ) : void
Результат void

ExitToEntry() публичный статический метод

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
Результат List

FromXML() публичный метод

public FromXML ( string input, Backend targetCoords = null, bool resetPlayer = false ) : void
input string
targetCoords Backend
resetPlayer bool
Результат void

GetCheckpointCoords() публичный метод

Get coordinates of checkpoint on map (if any)
public GetCheckpointCoords ( ) : Backend.Coords
Результат Backend.Coords

HandleEvent() публичный метод

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
Результат void

Load() публичный метод

public Load ( string filename, Backend targetCoords = null, bool resetPlayer = false, string subdir = "save\\auto\\" ) : void
filename string
targetCoords Backend
resetPlayer bool
subdir string
Результат void

Map() публичный метод

Basic constructor (creating an empty map)
public Map ( ) : System
Результат System

Map() публичный метод

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
Результат System

MoveActor() публичный метод

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
Результат void

NextDirection() публичный статический метод

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
Результат Direction

OppositeDirection() публичный статический метод

Find the exact opposite facing of a direction
public static OppositeDirection ( Direction dir ) : Direction
dir Direction Direction to start
Результат Direction

PathTo() публичный метод

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
Результат void

PositionActor() публичный метод

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
Результат void

ReadXML() публичный метод

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
Результат void

Save() публичный метод

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
Результат void

TileByCoords() публичный метод

Get tile specified by a coords-object (deprecated, use direct access by map[])
public TileByCoords ( Coords coords ) : FloorTile
coords Coords Coordinates of tile
Результат FloorTile

ToString() публичный метод

Display map & walls in text form
public ToString ( ) : string
Результат string

ToXML() публичный метод

Get the current Map as an XML-String
public ToXML ( ) : string
Результат string

Uncover() публичный метод

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
Результат void

Update() публичный метод

Refresh tiles which do something (traps, enemies, NPCs)
public Update ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime
Результат void

WhichWayIs() публичный статический метод

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
Результат Direction

firstActorID() публичный метод

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
Результат int

this() публичный метод

Get the tile at coordinates specified by a coords-object
public this ( Coords coords ) : FloorTile
coords Coords Coordinate object specifying the tile
Результат FloorTile

this() публичный метод

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
Результат FloorTile

Описание свойств

_actors защищенное свойство

A list of Actors in the current room
protected List _actors
Результат List

_dungeonname защищенное свойство

Descriptive name of current dungeon
protected string _dungeonname
Результат string

_exits защищенное свойство

A list of all exits from current room
protected List _exits
Результат List

_floorFile защищенное свойство

XML-File containing floor used in dungeon
protected string _floorFile
Результат string

_height защищенное свойство

Internal current height
protected int _height
Результат int

_id защищенное свойство

A unique ID-number for current room
protected int _id
Результат int

_level защищенное свойство

Level of current map (used to determine difficulty etc.)
protected int _level
Результат int

_light защищенное свойство

Ambient light in dungeon (higher value means increased radius)
protected int _light
Результат int

_music защищенное свойство

Reference to music used in room
protected string _music
Результат string

_name защищенное свойство

Descriptive name of current map
protected string _name
Результат string

_tiles защищенное свойство

A two dimensional list of tiles
protected List> _tiles
Результат List>

_updateTiles защищенное свойство

A list of tiles to update each cycle (save ressources)
protected HashSet _updateTiles
Результат HashSet

_wallFile защищенное свойство

XML-File containing tileset used in dungeon
protected string _wallFile
Результат string

_width защищенное свойство

Internal current width
protected int _width
Результат int