C# Класс GameEngine.Drawing.DrawableSet

A DrawableSet is a collection of IGameDrawable instances (each called a GameDrawableInstance), organised in a first-tier group of STATES. Whenever a STATE (e.g. Running, Walking) is given to a DrawableSet, it will return a list of all the GameDrawableInstances that were stored under that STATE. This provides a very quick and easy way of being able to retrieve items which are related at one go so that they may be drawn together on the screen. Optionally, a second tier grouping mechanism is given by exposing a GROUP variable in each GameDrawableInstance. This second tier grouping mechanism allows for items related to each other, but not necisseraly stored under the same STATE, to have their values set at one go in a batch operation. GameDrawableInstances are important becuase they allow draw options to be set per Entity Drawable, without effecting the draw state of other Entities using the same drawable item. For this reason, properties such as Visibility, Layer, Rotation, Color and SpriteEffects to use are all stored in a GameDrawableInstance rather than an IGameDrawable item. A very brief diagram showing the overview of this structure can be seen below: GameDrawableSet -----> [ STATE0 ] ------> {GameDrawableInstance1, GameDrawableInstance2, ..., GameDrawableInstanceN} -----> [ STATE1 ] ------> ... -----> ... -----> [ STATEN ] ------> ... Similiarly, the same applies for storing by GROUP. The access times of both these allocations is constant O(1) time due to the use of seperate dictionaries. GameDrawableInstance -------> {IGameDrawable, Visible, Rotation, Color, SpriteEffects, Layer }
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
Add ( string state, IGameDrawable drawable, string group = "" ) : DrawableInstance

Adds the specified IGameDrawable to this DrawableSet under the specified *state*. Optionally, the IGameDrawable being added can also be associated with a *group*. When an IGameDrawable is added to a DrawableSet, it is wrapped around a DrawableInstance class that allows properties about the drawable to be set such as its Color, Rotation, Visibility etc... This DrawableInstance that is created to wrap the IGameDrawable is returned by this method.

AddGroup ( string group ) : bool
AddState ( string state ) : bool
ClearAll ( ) : void

Clears all drawable items from this DrawableSet. After this opereation, this DrawableSet will have no more States or Groups.

GetByGroup ( string group ) : HashSet

Returns all the DrawableInstances associated with the *group* specified in the parameter. If the group does not exist within this DrawableSet, a null value is returned.

GetByState ( string state ) : HashSet

Returns all the DrawableInstances associated with the *state* specified in the parameter. If the group does not exist within this DrawableSet, a null value is returned.

GetGroups ( ) : ICollection

Returns a collection of all *groups* found within this DrawableSet.

GetStates ( ) : ICollection

Returns a collection of all *states* found within this DrawableSet.

IsGroupFinished ( string group, GameTime gameTime ) : bool
IsStateFinished ( string state, GameTime gameTime ) : bool
LoadDrawableSetXml ( DrawableSet drawableSet, string path, Microsoft.Xna.Framework.Content.ContentManager content, double startTimeMS ) : void

Loads a DrawableSet file into a specified DrawableSet object. The method requires the string path to the xml file containing the drawable data and a reference to the ContentManager. An optional Layer value can be specified for the ordering of the drawables in the DrawableSet. Currently only supports loading of Animation objects.

Remove ( DrawableInstance drawableInstance ) : bool

Removes the specified DrawableInstance from this DrawableSet. This will only work if the DrawableInstance belongs to this DrawableSet - it will not work if it belongs to another. Returns a true boolean value if the specified instance was found within this set and removed. If nothing was removed, a false value is returned.

Remove ( IGameDrawable drawable, string state ) : bool

Removes the DrawableInstance of the specified drawable from the specified set of this DrawableSet. Returns a true boolean value specifying if such an instance with the specified was found and removed. If nothing was removed, a false value is returned.

Remove ( DrawableSet drawableSet ) : void

Performs Set negation between this DrawableSet and the DrawabelSet specified in the parameter. While two sets should never share the same DrawableInstance, they may share the same IGameDrawable which would be wrapped by an DrawableInstance. If the DrawableSet specified in the parameter contains IGameDrawables within the same state as this DrawableSet, then associated DrawableInstance's are removed.

RemoveGroup ( string group ) : bool
RemoveState ( string state ) : bool
ResetGroup ( string group, GameTime gameTime ) : void

Asks all IGameDrawables within the specified *group* set to perform a Reset operation. By performing a Reset operation, each GameDrawable should act like it has just been created.

ResetState ( string state, GameTime gameTime ) : void

Asks all IGameDrawables within the specified *state* set to perform a Reset operation.

SetGroupProperty ( string group, string property, object value ) : void

Sets the specified property for all the DrawableInstances in the specified group using C# Reflection. The property to be set should be specified as a case sensitive string and its value should be set with an type that matches the Properties type. If the property specified does not exist in the DrawableInstance class, then an ArgumentException is thrown.

SetStateProperty ( string state, string property, object value ) : void

Sets the specified property for all the DrawableInstances in the specified state using C# Reflection. The property to be set should be specified as a case sensitive string and its value should be set with an type that matches the Properties type. If the property specified does not exist in the DrawableInstance class, then an ArgumentException is thrown.

ToString ( ) : string
Union ( DrawableSet drawableSet ) : void

Performs a Set union operation between this DrawableSet and the DrawableSet specified in the parameter. It is important to note that any IGameDrawables newly created in this DrawableSet are wrapped around a *new* DrawableInstance in order to allow properties to be set independently for each one.

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

Add() публичный Метод

Adds the specified IGameDrawable to this DrawableSet under the specified *state*. Optionally, the IGameDrawable being added can also be associated with a *group*. When an IGameDrawable is added to a DrawableSet, it is wrapped around a DrawableInstance class that allows properties about the drawable to be set such as its Color, Rotation, Visibility etc... This DrawableInstance that is created to wrap the IGameDrawable is returned by this method.
public Add ( string state, IGameDrawable drawable, string group = "" ) : DrawableInstance
state string
drawable IGameDrawable
group string
Результат DrawableInstance

AddGroup() публичный Метод

public AddGroup ( string group ) : bool
group string
Результат bool

AddState() публичный Метод

public AddState ( string state ) : bool
state string
Результат bool

ClearAll() публичный Метод

Clears all drawable items from this DrawableSet. After this opereation, this DrawableSet will have no more States or Groups.
public ClearAll ( ) : void
Результат void

GetByGroup() публичный Метод

Returns all the DrawableInstances associated with the *group* specified in the parameter. If the group does not exist within this DrawableSet, a null value is returned.
public GetByGroup ( string group ) : HashSet
group string
Результат HashSet

GetByState() публичный Метод

Returns all the DrawableInstances associated with the *state* specified in the parameter. If the group does not exist within this DrawableSet, a null value is returned.
public GetByState ( string state ) : HashSet
state string
Результат HashSet

GetGroups() публичный Метод

Returns a collection of all *groups* found within this DrawableSet.
public GetGroups ( ) : ICollection
Результат ICollection

GetStates() публичный Метод

Returns a collection of all *states* found within this DrawableSet.
public GetStates ( ) : ICollection
Результат ICollection

IsGroupFinished() публичный Метод

public IsGroupFinished ( string group, GameTime gameTime ) : bool
group string
gameTime Microsoft.Xna.Framework.GameTime
Результат bool

IsStateFinished() публичный Метод

public IsStateFinished ( string state, GameTime gameTime ) : bool
state string
gameTime Microsoft.Xna.Framework.GameTime
Результат bool

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

Loads a DrawableSet file into a specified DrawableSet object. The method requires the string path to the xml file containing the drawable data and a reference to the ContentManager. An optional Layer value can be specified for the ordering of the drawables in the DrawableSet. Currently only supports loading of Animation objects.
public static LoadDrawableSetXml ( DrawableSet drawableSet, string path, Microsoft.Xna.Framework.Content.ContentManager content, double startTimeMS ) : void
drawableSet DrawableSet DrawableSet object to load the animations into.
path string String path to the XML formatted .anim file
content Microsoft.Xna.Framework.Content.ContentManager Reference to the ContentManager instance being used in the application
startTimeMS double
Результат void

Remove() публичный Метод

Removes the specified DrawableInstance from this DrawableSet. This will only work if the DrawableInstance belongs to this DrawableSet - it will not work if it belongs to another. Returns a true boolean value if the specified instance was found within this set and removed. If nothing was removed, a false value is returned.
public Remove ( DrawableInstance drawableInstance ) : bool
drawableInstance DrawableInstance
Результат bool

Remove() публичный Метод

Removes the DrawableInstance of the specified drawable from the specified set of this DrawableSet. Returns a true boolean value specifying if such an instance with the specified was found and removed. If nothing was removed, a false value is returned.
public Remove ( IGameDrawable drawable, string state ) : bool
drawable IGameDrawable
state string
Результат bool

Remove() публичный Метод

Performs Set negation between this DrawableSet and the DrawabelSet specified in the parameter. While two sets should never share the same DrawableInstance, they may share the same IGameDrawable which would be wrapped by an DrawableInstance. If the DrawableSet specified in the parameter contains IGameDrawables within the same state as this DrawableSet, then associated DrawableInstance's are removed.
public Remove ( DrawableSet drawableSet ) : void
drawableSet DrawableSet
Результат void

RemoveGroup() публичный Метод

public RemoveGroup ( string group ) : bool
group string
Результат bool

RemoveState() публичный Метод

public RemoveState ( string state ) : bool
state string
Результат bool

ResetGroup() публичный Метод

Asks all IGameDrawables within the specified *group* set to perform a Reset operation. By performing a Reset operation, each GameDrawable should act like it has just been created.
public ResetGroup ( string group, GameTime gameTime ) : void
group string
gameTime Microsoft.Xna.Framework.GameTime
Результат void

ResetState() публичный Метод

Asks all IGameDrawables within the specified *state* set to perform a Reset operation.
public ResetState ( string state, GameTime gameTime ) : void
state string
gameTime Microsoft.Xna.Framework.GameTime
Результат void

SetGroupProperty() публичный Метод

Sets the specified property for all the DrawableInstances in the specified group using C# Reflection. The property to be set should be specified as a case sensitive string and its value should be set with an type that matches the Properties type. If the property specified does not exist in the DrawableInstance class, then an ArgumentException is thrown.
public SetGroupProperty ( string group, string property, object value ) : void
group string
property string
value object
Результат void

SetStateProperty() публичный Метод

Sets the specified property for all the DrawableInstances in the specified state using C# Reflection. The property to be set should be specified as a case sensitive string and its value should be set with an type that matches the Properties type. If the property specified does not exist in the DrawableInstance class, then an ArgumentException is thrown.
public SetStateProperty ( string state, string property, object value ) : void
state string
property string
value object
Результат void

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

public ToString ( ) : string
Результат string

Union() публичный Метод

Performs a Set union operation between this DrawableSet and the DrawableSet specified in the parameter. It is important to note that any IGameDrawables newly created in this DrawableSet are wrapped around a *new* DrawableInstance in order to allow properties to be set independently for each one.
public Union ( DrawableSet drawableSet ) : void
drawableSet DrawableSet
Результат void