C# Класс ScrollingShooter.GameObjectManager

A class for managing game objects
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
projectileObjects List
scrollingObjects List

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

Метод Описание
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

Приватные методы

Метод Описание
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

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

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

public CreateBoss ( BossType enemyType, Vector2 position ) : ScrollingShooter.Boss
enemyType BossType
position Vector2
Результат ScrollingShooter.Boss

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

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
Результат Enemy

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

Factory method for creating an explosion
public CreateExplosion ( uint colliderID ) : ScrollingShooter.Explosion
colliderID uint The source of the explosion
Результат ScrollingShooter.Explosion

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

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
Результат ScrollingShooter.Explosion2

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

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
Результат PlayerShip

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

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
Результат ScrollingShooter.Powerup

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

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
Результат ScrollingShooter.Projectile

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

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
Результат ScrollingShooter.Projectile

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

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
Результат ScrollingShooter.Shield

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

Removes the indicated game object from the game
public DestroyObject ( uint id ) : ScrollingShooter.GameObject
id uint The game object's ID
Результат ScrollingShooter.GameObject

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

Draws all game Objects
public Draw ( float elapsedTime, SpriteBatch spriteBatch ) : void
elapsedTime float
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch
Результат void

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

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
Результат System

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

Returns the GameObject instance corresponding to the specified game object id
public GetObject ( uint id ) : ScrollingShooter.GameObject
id uint The game object's ID
Результат ScrollingShooter.GameObject

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

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
Результат uint[]

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

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
Результат void

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

Updates the GameObjectManager, and all objects in the game
public Update ( float elapsedTime ) : void
elapsedTime float The time between this and the previous frame
Результат void

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

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
Результат void

Описание свойств

projectileObjects публичное свойство

public List projectileObjects
Результат List

scrollingObjects публичное свойство

public List scrollingObjects
Результат List