Otter
0.9.8.91
2d Game Development Framework based on SFML.Net
|
Class used to manage Entities. The active Game should update the active Scene, which then updates all of the contained Entities. More...
Public Member Functions | |
Scene (int width=0, int height=0) | |
Create a Scene with a specified width and height. If the width and height are not defined they will be inferred by the Game class that uses the Scene. More... | |
T | As< T > () |
A handy shortcut for casting the Scene as a specific scene type. For some reason I just like this better than doing (Scene as Type).Whatever(); More... | |
void | CenterCamera (float x, float y) |
Centers the camera of the scene. More... | |
T | Add< T > (T e) |
Add an entity to the scene. More... | |
T | Add< T > (params object[] constructorArgs) |
Create and add a new Entity to the Scene. More... | |
List< T > | Add< T > (List< T > entities) |
Add a list of Entities to the scene. More... | |
T | AddUnique< T > (T e) |
Adds an Entity only if no other Entities of that type exist in the Scene already. More... | |
T | AddUnique< T > (params object[] constructorArgs) |
Creates an adds an Entity to the Scene if there is no Entity of that type in the Scene already. More... | |
List< T > | AddUnique< T > (List< T > entities) |
Adds a list of Entities to the Scene if there is no Entity of that type added already. More... | |
List< Entity > | AddMultiple (params Entity[] entities) |
Add multiple entities to the scene. More... | |
T | SetGraphic< T > (T g) |
Set the only graphic of the scene. More... | |
T | AddGraphic< T > (T g) |
Adds a Graphic to the scene. More... | |
T | AddGraphic< T > (T g, float x, float y) |
Adds a Graphic to the Scene. More... | |
List< Graphic > | AddGraphics (params Graphic[] graphics) |
Add multiple graphics to the scene. More... | |
T | RemoveGraphic< T > (T g) |
Removes a Graphic from the scene. More... | |
void | ClearGraphics () |
Removes all Graphics from the scene. More... | |
T | AddGraphicGUI< T > (T g) |
Adds a Graphic to the Scene and sets its Scroll value to 0. More... | |
T | AddGraphicGUI< T > (T g, float x, float y) |
Adds a Graphic to the Scene and sets its Scroll value to 0. More... | |
List< Graphic > | AddGraphicsGUI (params Graphic[] graphics) |
Adds graphics to the Scene and sets their Scroll values to 0. More... | |
T | Remove< T > (T e) |
Removes an entity from the scene. More... | |
T | Remove< T > () |
Removes the first Entity of type T from the Scene. More... | |
void | Remove< T > (List< T > entities) |
void | RemoveAll () |
Remove all entities from the scene. More... | |
List< Entity > | RemoveMultiple (params Entity[] entities) |
T | RemoveNextFrame< T > (T e) |
void | AddSurface (Surface target) |
Add a surface to the list of surfaces that the scene should render to. This only applies to the Scene's graphics, NOT the entities in the scene. More... | |
void | RemoveSurface (Surface target) |
Remove a surface from the list of targets that the scene should render to. More... | |
void | ClearSurfaces () |
Remove all surface targets and revert back to the default game surface. More... | |
void | SendToBack (Entity e) |
Sends an Entity to the back of its layer. Probably don't use this and change the Entity's layer in the same update. More... | |
void | SendBackward (Entity e) |
Sends an Entity further back in its layer. Probably don't use this and change the Entity's layer in the same update. More... | |
void | BringForward (Entity e) |
Brings an Entity further forward in its layer. Probably don't use this and change the Entity's layer in the same update. More... | |
void | BringToFront (Entity e) |
Brings an Entity to the front of its layer. Probably don't use this and change the Entity's layer in the same update. More... | |
virtual void | Begin () |
Called when the scene begins after being switched to, or added to the stack. More... | |
virtual void | End () |
Called when the scene ends after being switched away from, or removed from the stack. More... | |
virtual void | Pause () |
Called when the scene is paused because a new scene is stacked on it. More... | |
virtual void | Resume () |
Called when the scene resumes after a scene is added above it. More... | |
virtual void | UpdateFirst () |
The first update of the scene. More... | |
virtual void | UpdateLast () |
The last update of the scene. More... | |
virtual void | Update () |
The main update loop of the scene. More... | |
virtual void | Render () |
Renders the scene. Graphics added to the scene render first. Graphics drawn in Render() will render on top of all entities. More... | |
void | UpdateLists () |
Update the internal lists stored by the scene. The engine will usually take care of this! More... | |
Tween | Tween (object target, object values, float duration, float delay=0) |
Tweens a set of numeric properties on an object. More... | |
void | PauseGroup (int group) |
Pause a group of entities. More... | |
void | ResumeGroup (int group) |
Resume a paused group of entities. More... | |
void | PauseGroupToggle (int group) |
Pause or resume a group of entities. If paused, resume. If running, pause. More... | |
bool | IsGroupPaused (int group) |
If a group of entities is currently paused. Note that pausing wont happen until the next update aftering calling pause. More... | |
List< Entity > | GetEntitiesInGroup (int group) |
Returns a list of all the entities in the given group. More... | |
List< Entity > | GetEntitiesInLayer (int layer) |
Returns a list of all the Entities in the given layer. More... | |
List< T > | GetEntities< T > () |
Get a list of entities of type T from the Scene. More... | |
List< Entity > | GetEntitiesAll () |
List< Entity > | GetEntities (Type t) |
Get a list of Entities of a type from the Scene. More... | |
T | GetEntity< T > () |
Get the first instance of an Entity of type T. More... | |
List< Entity > | GetEntities (int colliderTag) |
Get a list of Entities that have a Collider that matches a specified tag. More... | |
List< Entity > | GetEntities (Enum colliderTag) |
Get a list of Entities that have a Collider that matches a specified tag. More... | |
List< Entity > | GetEntitiesWith< T1 > () |
List< Entity > | GetEntitiesWith< T1, T2 > () |
List< Entity > | GetEntitiesWith< T1, T2, T3 > () |
List< Entity > | GetEntitiesWith< T1, T2, T3, T4 > () |
List< Entity > | GetEntitiesWith< T1, T2, T3, T4, T5 > () |
List< Entity > | GetEntitiesWith< T1, T2, T3, T4, T5, T6 > () |
List< Collider > | GetColliders (int tag) |
Get a list of Colliders that match a specified tag. More... | |
List< Collider > | GetColliders (Enum tag) |
Get a list of Colliders that match a specified tag. More... | |
Entity | GetTopEntity (params Entity[] entities) |
Get the top most Entity in the rendering order from a set of Entities. More... | |
Entity | GetBottomEntity (params Entity[] entities) |
Get the bottom most Entity in the rendering order from a set of Entities. More... | |
int | GetCount< T > () |
Count how many entities of type T are in this Scene. More... | |
Public Attributes | |
Tweener | Tweener = new Tweener() |
The Glide instance for this Scene to control all tweens. More... | |
float | Timer |
The current time since this Scene has started. More... | |
Action | OnUpdate = delegate { } |
An action that triggers during Update(). More... | |
Action | OnUpdateFirst = delegate { } |
An action that triggers during UpdateFirst(). More... | |
Action | OnUpdateLast = delegate { } |
An action that triggers during UpdateLast(). More... | |
Action | OnRender = delegate { } |
An action that triggers during Render(), after all entities have been rendered. More... | |
Action | OnBegin = delegate { } |
An action that triggers during Begin(). More... | |
Action | OnEnd = delegate { } |
An action that triggers during End(). More... | |
Action | OnAdd = delegate { } |
An action that triggers when an entity is Added. More... | |
Action | OnRemove = delegate { } |
An action that triggers when an entity is removed. More... | |
Action | OnPause = delegate { } |
An action that triggers when the Scene is paused because a Scene is stacked on top of it. More... | |
Action | OnResume = delegate { } |
An action that triggers when the Scene is resumed because the active Scene on top of it was popped. More... | |
Action | OnCameraUpdate = delegate { } |
An action that triggers after the Scene has updated the camera positions for the Game's Surfaces. More... | |
float | CameraAngle |
The angle of the camera. More... | |
float | CameraZoom = 1f |
The zoom of the camera. More... | |
int | Width |
The width of the scene. More... | |
int | Height |
The height of the scene. More... | |
bool | ApplyCamera = true |
Determines if the scene will control the game surface's camera. More... | |
bool | DrawScenesBelow = true |
Determines if scenes below this scene on the stack are allowed to render. More... | |
Rectangle | CameraBounds |
The bounds that the camera should be clamped inside. More... | |
bool | UseCameraBounds = false |
Determines if the camera will be clamped inside the CameraBounds rectangle. More... | |
Entity | CameraFocus |
The Entity that the Scene's camera will follow. More... | |
bool | Visible = true |
Determines if the scene will render its graphics or not. More... | |
Static Public Attributes | |
static Scene | Instance |
A reference back to the current scene being run by the game. More... | |
Properties | |
Game | Game [get, set] |
A reference to the Game that owns this Scene. More... | |
Surface | Surface [get, set] |
The default surface to render the scene's graphics to. If null then render to the default game surface. More... | |
List< Surface > | Surfaces [get, set] |
The list of surfaces the Scene should render to. More... | |
float | HalfWidth [get, set] |
Half of the scene's width. More... | |
float | HalfHeight [get, set] |
Half of the scene's height. More... | |
Vector2 | Center [get] |
Input | Input [get] |
A reference to the Input from the Game controlling this scene. More... | |
int | EntityCount [get] |
The current number of entities in the scene. More... | |
float | MouseX [get] |
The current mouse X position in relation to the scene space. More... | |
float | MouseY [get] |
The current mouse Y position in relation to the scene space. More... | |
float | MouseRawX [get] |
The current raw mouse X position in relation to the scene space. More... | |
float | MouseRawY [get] |
The current raw mouse Y position in relation to the scene space. More... | |
float | CameraX [get, set] |
The X position of the camera in the scene. More... | |
float | CameraCenterX [get] |
The X position of the center of the camera. More... | |
float | CameraCenterY [get] |
The Y position of the center of the camera. More... | |
float | CameraY [get, set] |
The Y position of the camera in the scene. More... | |
float | CameraWidth [get] |
The width in pixels that the camera is showing with the current zoom. More... | |
float | CameraHeight [get] |
The height in pixels that the camera is showing with the current zoom. More... | |
Rectangle | Bounds [get] |
The bounds of the Scene as a Rectangle. More... | |
Debugger | Debugger [get] |
A reference to the debugger object from the game that owns this scene. More... | |
Entity | this[int id] [get] |
Class used to manage Entities. The active Game should update the active Scene, which then updates all of the contained Entities.
Otter.Scene.Scene | ( | int | width = 0 , |
int | height = 0 |
||
) |
T Otter.Scene.Add< T > | ( | T | e | ) |
Add an entity to the scene.
e | Adds a new entity |
T | : | Entity |
T Otter.Scene.Add< T > | ( | params object[] | constructorArgs | ) |
List<T> Otter.Scene.Add< T > | ( | List< T > | entities | ) |
Add a list of Entities to the scene.
T | The type of Entity. |
entities | The list of Entities. |
T | : | Entity |
T Otter.Scene.AddGraphic< T > | ( | T | g | ) |
T Otter.Scene.AddGraphic< T > | ( | T | g, |
float | x, | ||
float | y | ||
) |
T Otter.Scene.AddGraphicGUI< T > | ( | T | g | ) |
T Otter.Scene.AddGraphicGUI< T > | ( | T | g, |
float | x, | ||
float | y | ||
) |
Add multiple graphics to the scene.
graphics | The graphics. |
Adds graphics to the Scene and sets their Scroll values to 0.
T |
graphics | The graphics to add. |
Add multiple entities to the scene.
entities | The entities to add. |
void Otter.Scene.AddSurface | ( | Surface | target | ) |
Add a surface to the list of surfaces that the scene should render to. This only applies to the Scene's graphics, NOT the entities in the scene.
target |
T Otter.Scene.AddUnique< T > | ( | T | e | ) |
T Otter.Scene.AddUnique< T > | ( | params object[] | constructorArgs | ) |
List<T> Otter.Scene.AddUnique< T > | ( | List< T > | entities | ) |
T Otter.Scene.As< T > | ( | ) |
|
virtual |
Called when the scene begins after being switched to, or added to the stack.
void Otter.Scene.BringForward | ( | Entity | e | ) |
void Otter.Scene.BringToFront | ( | Entity | e | ) |
void Otter.Scene.CenterCamera | ( | float | x, |
float | y | ||
) |
Centers the camera of the scene.
x | The x coordinate to be the center of the scene. |
y | The y coordinate to be the center of the scene. |
void Otter.Scene.ClearGraphics | ( | ) |
Removes all Graphics from the scene.
void Otter.Scene.ClearSurfaces | ( | ) |
Remove all surface targets and revert back to the default game surface.
|
virtual |
Called when the scene ends after being switched away from, or removed from the stack.
List<Collider> Otter.Scene.GetColliders | ( | int | tag | ) |
Get a list of Colliders that match a specified tag.
tag | The tag to search for. |
List<Collider> Otter.Scene.GetColliders | ( | Enum | tag | ) |
Get a list of Colliders that match a specified tag.
tag | The tag to search for. |
int Otter.Scene.GetCount< T > | ( | ) |
Count how many entities of type T are in this Scene.
T | The type of entity to count. |
T | : | Entity |
List<Entity> Otter.Scene.GetEntities | ( | Type | t | ) |
List<Entity> Otter.Scene.GetEntities | ( | int | colliderTag | ) |
List<Entity> Otter.Scene.GetEntities | ( | Enum | colliderTag | ) |
List<T> Otter.Scene.GetEntities< T > | ( | ) |
Get a list of entities of type T from the Scene.
T | The type of entity to collect. |
T | : | Entity |
List<Entity> Otter.Scene.GetEntitiesInGroup | ( | int | group | ) |
Returns a list of all the entities in the given group.
group | The group to get. |
List<Entity> Otter.Scene.GetEntitiesInLayer | ( | int | layer | ) |
Returns a list of all the Entities in the given layer.
layer | The layer to get. |
T Otter.Scene.GetEntity< T > | ( | ) |
Get the first instance of an Entity of type T.
T | The entity type to search for. |
T | : | Entity |
bool Otter.Scene.IsGroupPaused | ( | int | group | ) |
If a group of entities is currently paused. Note that pausing wont happen until the next update aftering calling pause.
group | The group to check. |
|
virtual |
Called when the scene is paused because a new scene is stacked on it.
void Otter.Scene.PauseGroup | ( | int | group | ) |
Pause a group of entities.
group | The group to pause. |
void Otter.Scene.PauseGroupToggle | ( | int | group | ) |
Pause or resume a group of entities. If paused, resume. If running, pause.
group | The group to toggle. |
T Otter.Scene.Remove< T > | ( | T | e | ) |
Removes an entity from the scene.
T | The type (inferred from the parameter.) |
e | The entity to remove. |
T | : | Entity |
T Otter.Scene.Remove< T > | ( | ) |
void Otter.Scene.RemoveAll | ( | ) |
Remove all entities from the scene.
T Otter.Scene.RemoveGraphic< T > | ( | T | g | ) |
void Otter.Scene.RemoveSurface | ( | Surface | target | ) |
Remove a surface from the list of targets that the scene should render to.
target |
|
virtual |
Renders the scene. Graphics added to the scene render first. Graphics drawn in Render() will render on top of all entities.
|
virtual |
Called when the scene resumes after a scene is added above it.
void Otter.Scene.ResumeGroup | ( | int | group | ) |
Resume a paused group of entities.
group | The group to resume. |
void Otter.Scene.SendBackward | ( | Entity | e | ) |
void Otter.Scene.SendToBack | ( | Entity | e | ) |
T Otter.Scene.SetGraphic< T > | ( | T | g | ) |
Set the only graphic of the scene.
g | The graphic. |
T | : | Graphic |
Tween Otter.Scene.Tween | ( | object | target, |
object | values, | ||
float | duration, | ||
float | delay = 0 |
||
) |
Tweens a set of numeric properties on an object.
target | The object to tween. |
values | The values to tween to, in an anonymous type ( new { prop1 = 100, prop2 = 0} ). |
duration | Duration of the tween in seconds. |
delay | Delay before the tween starts, in seconds. |
|
virtual |
The main update loop of the scene.
|
virtual |
The first update of the scene.
|
virtual |
The last update of the scene.
void Otter.Scene.UpdateLists | ( | ) |
Update the internal lists stored by the scene. The engine will usually take care of this!
bool Otter.Scene.ApplyCamera = true |
Determines if the scene will control the game surface's camera.
float Otter.Scene.CameraAngle |
The angle of the camera.
Rectangle Otter.Scene.CameraBounds |
The bounds that the camera should be clamped inside.
float Otter.Scene.CameraZoom = 1f |
The zoom of the camera.
bool Otter.Scene.DrawScenesBelow = true |
Determines if scenes below this scene on the stack are allowed to render.
int Otter.Scene.Height |
The height of the scene.
|
static |
A reference back to the current scene being run by the game.
Action Otter.Scene.OnAdd = delegate { } |
An action that triggers when an entity is Added.
Action Otter.Scene.OnBegin = delegate { } |
An action that triggers during Begin().
Action Otter.Scene.OnCameraUpdate = delegate { } |
Action Otter.Scene.OnEnd = delegate { } |
An action that triggers during End().
Action Otter.Scene.OnPause = delegate { } |
Action Otter.Scene.OnRemove = delegate { } |
An action that triggers when an entity is removed.
Action Otter.Scene.OnRender = delegate { } |
An action that triggers during Render(), after all entities have been rendered.
Action Otter.Scene.OnResume = delegate { } |
Action Otter.Scene.OnUpdate = delegate { } |
An action that triggers during Update().
Action Otter.Scene.OnUpdateFirst = delegate { } |
An action that triggers during UpdateFirst().
Action Otter.Scene.OnUpdateLast = delegate { } |
An action that triggers during UpdateLast().
float Otter.Scene.Timer |
The current time since this Scene has started.
The Glide instance for this Scene to control all tweens.
bool Otter.Scene.UseCameraBounds = false |
Determines if the camera will be clamped inside the CameraBounds rectangle.
bool Otter.Scene.Visible = true |
Determines if the scene will render its graphics or not.
int Otter.Scene.Width |
The width of the scene.
|
get |
The X position of the center of the camera.
|
get |
The Y position of the center of the camera.
|
get |
The height in pixels that the camera is showing with the current zoom.
|
get |
The width in pixels that the camera is showing with the current zoom.
|
getset |
The X position of the camera in the scene.
|
getset |
The Y position of the camera in the scene.
|
get |
A reference to the debugger object from the game that owns this scene.
|
get |
The current number of entities in the scene.
|
getset |
Half of the scene's height.
|
getset |
Half of the scene's width.
|
get |
The current raw mouse X position in relation to the scene space.
|
get |
The current raw mouse Y position in relation to the scene space.
|
get |
The current mouse X position in relation to the scene space.
|
get |
The current mouse Y position in relation to the scene space.
|
getset |
The default surface to render the scene's graphics to. If null then render to the default game surface.