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