C# Class FuncWorks.XNA.XTiled.Map

An XTiled TMX Map
Show file Open project: Bacon41/PantheonPrototype Class Usage Examples

Public Properties

Property Type Description
Bounds Microsoft.Xna.Framework.Rectangle
Height Int32
LayerOrder LayerInfo[]
LoadTextures Boolean
ObjectLayers ObjectLayerList
Orientation MapOrientation
Properties Property>.Dictionary
SourceTiles Tile[]
TileHeight Int32
TileLayers TileLayerList
TileWidth Int32
Tilesets Tileset[]
Width Int32

Public Methods

Method Description
Draw ( SpriteBatch spriteBatch, Rectangle region ) : void

Draws all visible tile layers

Draw ( SpriteBatch spriteBatch, Rectangle region, System.Boolean drawHiddenLayers ) : void

Draws all visible tile layers

DrawLayer ( SpriteBatch spriteBatch, Int32 layerID, Rectangle region, System.Single layerDepth ) : void

Draws given tile layer

DrawMapObject ( SpriteBatch spriteBatch, Int32 objectLayerID, Int32 objectID, Rectangle region, System.Single layerDepth ) : void

Method to draw a MapObject

DrawObjectLayer ( SpriteBatch spriteBatch, Int32 objectLayerID, Rectangle region, System.Single layerDepth ) : void

Draws all objects on the given object layer

DrawRectangle ( SpriteBatch spriteBatch, Rectangle rect, Rectangle region, System.Single layerDepth, Color linecolor, Color fillColor ) : void

Method to draw a Rectangle

DrawTileObject ( SpriteBatch spriteBatch, Int32 objectLayerID, Int32 objectID, Rectangle region, System.Single layerDepth, Color color ) : void

Method to draw a MapObject that represents a tile object

DrawTileObject ( SpriteBatch spriteBatch, int objectLayerID, int objectID, Rectangle &region, float layerDepth, Color &color ) : void

Method to draw a MapObject that represents a tile object

GetObjectsInRegion ( Int32 objectLayerID, Rectangle region ) : IEnumerable

Returns a collection of MapObjects inside the given region

GetObjectsInRegion ( Rectangle region ) : IEnumerable

Returns a collection of MapObjects inside the given region

GetTilesInRegion ( Int32 tileLayerID, Rectangle region ) : IEnumerable

Returns a collection of TileData inside the given region

GetTilesInRegion ( Rectangle region ) : IEnumerable

Returns a collection of TileData inside the given region

InitObjectDrawing ( GraphicsDevice graphicsDevice ) : void

Enables rendering of map objects

Translate ( Point location, Rectangle relativeTo ) : Point

Translates a location to screen space

Translate ( Rectangle location, Rectangle relativeTo ) : Rectangle

Translates a location to screen space

Translate ( Vector2 location, Rectangle relativeTo ) : Vector2

Translates a location to screen space

Translate ( Point &location, Rectangle &relativeTo ) : void

Translates a location to screen space

Translate ( Rectangle &location, Rectangle &relativeTo ) : void

Translates a location to screen space

Translate ( Vector2 &location, Rectangle &relativeTo ) : void

Translates a location to screen space

Private Methods

Method Description
CreatePolygonTextures ( ) : void
DrawLayer ( SpriteBatch spriteBatch, Int32 layerID, Rectangle &region, Int32 txMin, Int32 txMax, Int32 tyMin, Int32 tyMax, System.Single layerDepth ) : void

Method Details

Draw() public method

Draws all visible tile layers
public Draw ( SpriteBatch spriteBatch, Rectangle region ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch XNA SpriteBatch instance; SpriteBatch.Begin() must be called before using this method
region Microsoft.Xna.Framework.Rectangle Region of the map in pixels to draw
return void

Draw() public method

Draws all visible tile layers
public Draw ( SpriteBatch spriteBatch, Rectangle region, System.Boolean drawHiddenLayers ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch XNA SpriteBatch instance; SpriteBatch.Begin() must be called before using this method
region Microsoft.Xna.Framework.Rectangle Region of the map in pixels to draw
drawHiddenLayers System.Boolean If true, draws layers regardless of TileLayer.Visible flag
return void

DrawLayer() public method

Draws given tile layer
public DrawLayer ( SpriteBatch spriteBatch, Int32 layerID, Rectangle region, System.Single layerDepth ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch XNA SpriteBatch instance; SpriteBatch.Begin() must be called before using this method
layerID System.Int32 Index of the layer to draw in the Map.TileLayers collection
region Microsoft.Xna.Framework.Rectangle Region of the map in pixels to draw
layerDepth System.Single LayerDepth value to pass to SpriteBatch
return void

DrawMapObject() public method

Method to draw a MapObject
public DrawMapObject ( SpriteBatch spriteBatch, Int32 objectLayerID, Int32 objectID, Rectangle region, System.Single layerDepth ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch XNA SpriteBatch instance; SpriteBatch.Begin() must be called before using this method
objectLayerID System.Int32 Index of the layer to draw in the Map.ObjectLayers collection
objectID System.Int32 Index of the object to draw in the Map.ObjectLayers.MapObjects collection
region Microsoft.Xna.Framework.Rectangle Region of the map in pixels to draw
layerDepth System.Single LayerDepth value to pass to SpriteBatch
return void

DrawObjectLayer() public method

Draws all objects on the given object layer
public DrawObjectLayer ( SpriteBatch spriteBatch, Int32 objectLayerID, Rectangle region, System.Single layerDepth ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch XNA SpriteBatch instance; SpriteBatch.Begin() must be called before using this method
objectLayerID System.Int32 Index of the layer to draw in the Map.ObjectLayers collection
region Microsoft.Xna.Framework.Rectangle Region of the map in pixels to draw
layerDepth System.Single LayerDepth value to pass to SpriteBatch
return void

DrawRectangle() public static method

Method to draw a Rectangle
public static DrawRectangle ( SpriteBatch spriteBatch, Rectangle rect, Rectangle region, System.Single layerDepth, Color linecolor, Color fillColor ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch XNA SpriteBatch instance; SpriteBatch.Begin() must be called before using this method
rect Microsoft.Xna.Framework.Rectangle The Rectangle to draw, in map pixels
region Microsoft.Xna.Framework.Rectangle Region of the map in pixels currently visible
layerDepth System.Single LayerDepth value to pass to SpriteBatch
linecolor Color Color of the Rectangle border
fillColor Color Color to fill the Rectangle with
return void

DrawTileObject() public method

Method to draw a MapObject that represents a tile object
public DrawTileObject ( SpriteBatch spriteBatch, Int32 objectLayerID, Int32 objectID, Rectangle region, System.Single layerDepth, Color color ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch XNA SpriteBatch instance; SpriteBatch.Begin() must be called before using this method
objectLayerID System.Int32 Index of the layer to draw in the Map.ObjectLayers collection
objectID System.Int32 Index of the object to draw in the Map.ObjectLayers.MapObjects collection
region Microsoft.Xna.Framework.Rectangle Region of the map in pixels to draw
layerDepth System.Single LayerDepth value to pass to SpriteBatch
color Color Color of the object
return void

DrawTileObject() public method

Method to draw a MapObject that represents a tile object
public DrawTileObject ( SpriteBatch spriteBatch, int objectLayerID, int objectID, Rectangle &region, float layerDepth, Color &color ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch XNA SpriteBatch instance; SpriteBatch.Begin() must be called before using this method
objectLayerID int Index of the layer to draw in the Map.ObjectLayers collection
objectID int Index of the object to draw in the Map.ObjectLayers.MapObjects collection
region Microsoft.Xna.Framework.Rectangle Region of the map in pixels to draw
layerDepth float LayerDepth value to pass to SpriteBatch
color Color Color of the object
return void

GetObjectsInRegion() public method

Returns a collection of MapObjects inside the given region
public GetObjectsInRegion ( Int32 objectLayerID, Rectangle region ) : IEnumerable
objectLayerID System.Int32 The object layer to check
region Microsoft.Xna.Framework.Rectangle The region, in pixles, to check
return IEnumerable

GetObjectsInRegion() public method

Returns a collection of MapObjects inside the given region
public GetObjectsInRegion ( Rectangle region ) : IEnumerable
region Microsoft.Xna.Framework.Rectangle The region, in pixles, to check
return IEnumerable

GetTilesInRegion() public method

Returns a collection of TileData inside the given region
public GetTilesInRegion ( Int32 tileLayerID, Rectangle region ) : IEnumerable
tileLayerID System.Int32 The tile layer to check
region Microsoft.Xna.Framework.Rectangle The region, in pixles, to check
return IEnumerable

GetTilesInRegion() public method

Returns a collection of TileData inside the given region
public GetTilesInRegion ( Rectangle region ) : IEnumerable
region Microsoft.Xna.Framework.Rectangle The region, in pixles, to check
return IEnumerable

InitObjectDrawing() public static method

Enables rendering of map objects
public static InitObjectDrawing ( GraphicsDevice graphicsDevice ) : void
graphicsDevice GraphicsDevice The graphics device to us in creating textures to support object rendering
return void

Translate() public static method

Translates a location to screen space
public static Translate ( Point location, Rectangle relativeTo ) : Point
location Point The location in map pixel coordinates
relativeTo Rectangle Region of the map that is on screen
return Point

Translate() public static method

Translates a location to screen space
public static Translate ( Rectangle location, Rectangle relativeTo ) : Rectangle
location Rectangle The location in map pixel coordinates
relativeTo Rectangle Region of the map that is on screen
return Rectangle

Translate() public static method

Translates a location to screen space
public static Translate ( Vector2 location, Rectangle relativeTo ) : Vector2
location Vector2 The location in map pixel coordinates
relativeTo Rectangle Region of the map that is on screen
return Vector2

Translate() public static method

Translates a location to screen space
public static Translate ( Point &location, Rectangle &relativeTo ) : void
location Point The location in map pixel coordinates
relativeTo Rectangle Region of the map that is on screen
return void

Translate() public static method

Translates a location to screen space
public static Translate ( Rectangle &location, Rectangle &relativeTo ) : void
location Rectangle The location in map pixel coordinates
relativeTo Rectangle Region of the map that is on screen
return void

Translate() public static method

Translates a location to screen space
public static Translate ( Vector2 &location, Rectangle &relativeTo ) : void
location Vector2 The location in map pixel coordinates
relativeTo Rectangle Region of the map that is on screen
return void

Property Details

Bounds public property

Size of the map in pixels
public Rectangle,Microsoft.Xna.Framework Bounds
return Microsoft.Xna.Framework.Rectangle

Height public property

Height, in tiles, of the map
public Int32 Height
return Int32

LayerOrder public property

Order of tile and object layers combined, first is the bottom layer
public LayerInfo[] LayerOrder
return LayerInfo[]

LoadTextures public property

True if XTiled loaded tileset textures during map load
public Boolean LoadTextures
return Boolean

ObjectLayers public property

Ordered collection of object layers; first is the bottom layer
public ObjectLayerList ObjectLayers
return ObjectLayerList

Orientation public property

Orientation of the map.
public MapOrientation Orientation
return MapOrientation

Properties public property

Custom properties
public Dictionary Properties
return Property>.Dictionary

SourceTiles public property

List of all source tiles from tilesets
public Tile[] SourceTiles
return Tile[]

TileHeight public property

Pixel height of a single tile
public Int32 TileHeight
return Int32

TileLayers public property

Ordered collection of tile layers; first is the bottom layer
public TileLayerList TileLayers
return TileLayerList

TileWidth public property

Pixel width of a single tile
public Int32 TileWidth
return Int32

Tilesets public property

Tilesets associated with this map
public Tileset[] Tilesets
return Tileset[]

Width public property

Width, in tiles, of the map
public Int32 Width
return Int32