C# Class ScrollingShooter.GameObjectManager

A class for managing game objects
Afficher le fichier Open project: zombiepaladin/scrolling-shooter Class Usage Examples

Méthodes publiques

Свойство Type Description
projectileObjects List
scrollingObjects List

Méthodes publiques

Méthode 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

Méthode 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 méthode

public CreateBoss ( BossType enemyType, Vector2 position ) : ScrollingShooter.Boss
enemyType BossType
position Vector2
Résultat ScrollingShooter.Boss

CreateEnemy() public méthode

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
Résultat Enemy

CreateExplosion() public méthode

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

CreateExplosion2() public méthode

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
Résultat ScrollingShooter.Explosion2

CreatePlayerShip() public méthode

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
Résultat PlayerShip

CreatePowerup() public méthode

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
Résultat ScrollingShooter.Powerup

CreateProjectile() public méthode

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
Résultat ScrollingShooter.Projectile

CreateProjectile() public méthode

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
Résultat ScrollingShooter.Projectile

CreateShield() public méthode

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
Résultat ScrollingShooter.Shield

DestroyObject() public méthode

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

Draw() public méthode

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

GameObjectManager() public méthode

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
Résultat System

GetObject() public méthode

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

QueryRegion() public méthode

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
Résultat uint[]

Reset() public méthode

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
Résultat void

Update() public méthode

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

UpdateGameObject() public méthode

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
Résultat void

Property Details

projectileObjects public_oe property

public List projectileObjects
Résultat List

scrollingObjects public_oe property

public List scrollingObjects
Résultat List