C# Class ScrollingShooter.GameObjectManager

A class for managing game objects
Exibir arquivo Open project: zombiepaladin/scrolling-shooter Class Usage Examples

Public Properties

Property Type Description
projectileObjects List
scrollingObjects List

Public Methods

Method Description
CreateBoss ( BossType enemyType, Vector2 position ) : ScrollingShooter.Boss
CreateEnemy ( EnemyType enemyType, Vector2 position ) : Enemy

Factory method for spawning enemies.

CreateExplosion ( uint colliderID ) : ScrollingShooter.Explosion

Factory method for creating an explosion

CreateExplosion2 ( uint colliderID, float scale ) : ScrollingShooter.Explosion2

Factory method for creating an explosion

CreatePlayerShip ( PlayerShipType PlayerShipType, Vector2 position ) : PlayerShip

Factory method to create a Player ship

CreatePowerup ( PowerupType powerupType, Vector2 position ) : ScrollingShooter.Powerup

Factory method for spawning a projectile

CreateProjectile ( ProjectileType projectileType, Vector2 position ) : ScrollingShooter.Projectile

Factory method for spawning a projectile

CreateProjectile ( ProjectileType projectileType, Vector2 position, Vector2 velocity ) : ScrollingShooter.Projectile

Factory method for spawning a projectile

CreateShield ( ShieldType shieldType, Vector2 position, PlayerShip PlayerShip ) : ScrollingShooter.Shield

Factory method for spawning a shield

DestroyObject ( uint id ) : ScrollingShooter.GameObject

Removes the indicated game object from the game

Draw ( float elapsedTime, SpriteBatch spriteBatch ) : void

Draws all game Objects

GameObjectManager ( Microsoft.Xna.Framework.Content.ContentManager content ) : System

Constructs a new GameObjectManager instance

GetObject ( uint id ) : ScrollingShooter.GameObject

Returns the GameObject instance corresponding to the specified game object id

QueryRegion ( Rectangle bounds ) : uint[]

Queries a rectangular region and retuns game object ids for all game objects within that region

Reset ( PlayerShip player ) : void

Clear all of the Queues, lists, and Dictionarys and readd the Player This reloads the level while maintaining the player's score, lives, and powerups.

Update ( float elapsedTime ) : void

Updates the GameObjectManager, and all objects in the game

UpdateGameObject ( uint gameObjectID ) : void

Updates the position of a GameObject within the axis lists

Private Methods

Method Description
AddGameObject ( ScrollingShooter.GameObject gameObject ) : void

Helper method that adds a GameObject to the GameObjectManager

InsertBoundIntoAxis ( List axis, Bound bound ) : int

Inserts a new bound into an axis list. The list is assumed to be sorted, so the method uses binary insertion for speed.

NextID ( ) : uint

Helper method that provides the next unique game object ID

QueueGameObjectForCreation ( ScrollingShooter.GameObject go ) : void

Helper method for enqueueing our game object for creation at the start of the next update cycle.

RemoveGameObject ( ScrollingShooter.GameObject gameObject ) : void

Removes a Game object from the axis

UpdateAxisLists ( ) : void

Sorts the axis using insertion sort - provided the list is already nearly sorted, this should happen very quickly

Method Details

CreateBoss() public method

public CreateBoss ( BossType enemyType, Vector2 position ) : ScrollingShooter.Boss
enemyType BossType
position Vector2
return ScrollingShooter.Boss

CreateEnemy() public method

Factory method for spawning enemies.
public CreateEnemy ( EnemyType enemyType, Vector2 position ) : Enemy
enemyType EnemyType The type of enemy to spawn
position Vector2 The location to spawn the enemy
return Enemy

CreateExplosion() public method

Factory method for creating an explosion
public CreateExplosion ( uint colliderID ) : ScrollingShooter.Explosion
colliderID uint The source of the explosion
return ScrollingShooter.Explosion

CreateExplosion2() public method

Factory method for creating an explosion
public CreateExplosion2 ( uint colliderID, float scale ) : ScrollingShooter.Explosion2
colliderID uint The source of the explosion
scale float The scale of the explosion
return ScrollingShooter.Explosion2

CreatePlayerShip() public method

Factory method to create a Player ship
public CreatePlayerShip ( PlayerShipType PlayerShipType, Vector2 position ) : PlayerShip
PlayerShipType PlayerShipType The type of Player ship to create
position Vector2 The position of the Player ship in the game world
return PlayerShip

CreatePowerup() public method

Factory method for spawning a projectile
public CreatePowerup ( PowerupType powerupType, Vector2 position ) : ScrollingShooter.Powerup
powerupType PowerupType
position Vector2 The position of the projectile in the game world
return ScrollingShooter.Powerup

CreateProjectile() public method

Factory method for spawning a projectile
public CreateProjectile ( ProjectileType projectileType, Vector2 position ) : ScrollingShooter.Projectile
projectileType ProjectileType The type of projectile to create
position Vector2 The position of the projectile in the game world
return ScrollingShooter.Projectile

CreateProjectile() public method

Factory method for spawning a projectile
public CreateProjectile ( ProjectileType projectileType, Vector2 position, Vector2 velocity ) : ScrollingShooter.Projectile
projectileType ProjectileType The type of projectile to create
position Vector2 The position of the projectile in the game world
velocity Vector2
return ScrollingShooter.Projectile

CreateShield() public method

Factory method for spawning a shield
public CreateShield ( ShieldType shieldType, Vector2 position, PlayerShip PlayerShip ) : ScrollingShooter.Shield
shieldType ShieldType The type of shield to create
position Vector2 Position of the shield in the game world
PlayerShip PlayerShip The Player
return ScrollingShooter.Shield

DestroyObject() public method

Removes the indicated game object from the game
public DestroyObject ( uint id ) : ScrollingShooter.GameObject
id uint The game object's ID
return ScrollingShooter.GameObject

Draw() public method

Draws all game Objects
public Draw ( float elapsedTime, SpriteBatch spriteBatch ) : void
elapsedTime float
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch
return void

GameObjectManager() public method

Constructs a new GameObjectManager instance
public GameObjectManager ( Microsoft.Xna.Framework.Content.ContentManager content ) : System
content Microsoft.Xna.Framework.Content.ContentManager A ContentManager to use in loading assets
return System

GetObject() public method

Returns the GameObject instance corresponding to the specified game object id
public GetObject ( uint id ) : ScrollingShooter.GameObject
id uint The game object's ID
return ScrollingShooter.GameObject

QueryRegion() public method

Queries a rectangular region and retuns game object ids for all game objects within that region
public QueryRegion ( Rectangle bounds ) : uint[]
bounds Microsoft.Xna.Framework.Rectangle A bounding rectangle for the region of interest
return uint[]

Reset() public method

Clear all of the Queues, lists, and Dictionarys and readd the Player This reloads the level while maintaining the player's score, lives, and powerups.
public Reset ( PlayerShip player ) : void
player PlayerShip The player
return void

Update() public method

Updates the GameObjectManager, and all objects in the game
public Update ( float elapsedTime ) : void
elapsedTime float The time between this and the previous frame
return void

UpdateGameObject() public method

Updates the position of a GameObject within the axis lists
public UpdateGameObject ( uint gameObjectID ) : void
gameObjectID uint The ID of the game object to update
return void

Property Details

projectileObjects public_oe property

public List projectileObjects
return List

scrollingObjects public_oe property

public List scrollingObjects
return List