C# Class EtherDuels.Game.GameController

The GameController is responsible for the communication between the GameModel and its GameView. It creates new worlds and its views via a GameBuilder and can remove and add objects to them. It also observes whether a game has ended or was paused and informs its GameHandler if necessary.
Inheritance: CollisionHandler, PlayerHandler
Show file Open project: julius/pse_spacewar

Public Methods

Method Description
CreateGame ( ) : void

Creates a new game using its dedicated GameBuilder. A game consists of a model and its view.

Draw ( Viewport viewPort, SpriteBatch spriteBatch, GameTime gameTime ) : void

Draws the GameView and all its subcomponents.

GameController ( GameBuilder gameBuilder, GameHandler gameHandler ) : System

Constructor of a GameController object.

OnCollision ( WorldObject collisionObject1, WorldObject collisionObject2 ) : void

Reacts to a collision that happend in the game depending on the type of the two assigned WorldObjects. This method creates an explosion, reduces the health of the WorldObject, if necessary, and checks, if one of the involved world objects has to be removed from the world.

OnFire ( Spaceship shooter ) : void

Creates a projectile and its fitting view.

Update ( FrameState frameState ) : void

Updates the GameModel and its subcomponents.

Private Methods

Method Description
checkDeath ( WorldObject collisionObject, WorldObjectView worldObjectViews ) : void

Method Details

CreateGame() public method

Creates a new game using its dedicated GameBuilder. A game consists of a model and its view.
public CreateGame ( ) : void
return void

Draw() public method

Draws the GameView and all its subcomponents.
public Draw ( Viewport viewPort, SpriteBatch spriteBatch, GameTime gameTime ) : void
viewPort Microsoft.Xna.Framework.Graphics.Viewport Defines the Viewport to usw.
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch Defines the SpriteBatch to use.
gameTime Microsoft.Xna.Framework.GameTime The frame's time object.
return void

GameController() public method

Constructor of a GameController object.
public GameController ( GameBuilder gameBuilder, GameHandler gameHandler ) : System
gameBuilder GameBuilder Defines the GameBuilder the GameController uses.
gameHandler GameHandler Defines the GameHandler the GameController uses.
return System

OnCollision() public method

Reacts to a collision that happend in the game depending on the type of the two assigned WorldObjects. This method creates an explosion, reduces the health of the WorldObject, if necessary, and checks, if one of the involved world objects has to be removed from the world.
public OnCollision ( WorldObject collisionObject1, WorldObject collisionObject2 ) : void
collisionObject1 EtherDuels.Game.Model.WorldObject The first WorldObject, which was involved in the collision.
collisionObject2 EtherDuels.Game.Model.WorldObject The second WorldObject, which was involved in the collision.
return void

OnFire() public method

Creates a projectile and its fitting view.
public OnFire ( Spaceship shooter ) : void
shooter Spaceship The Spaceship which fired the projectile.
return void

Update() public method

Updates the GameModel and its subcomponents.
public Update ( FrameState frameState ) : void
frameState FrameState
return void