moagg.game.control
Class AbstractGameControlImpl

java.lang.Object
  extended by moagg.game.control.AbstractGameControlImpl
All Implemented Interfaces:
GameControl, InternalGameControl
Direct Known Subclasses:
MultiPlayerClientGameControlImpl, MultiPlayerServerGameControlImpl, SinglePlayerGameControlImpl

public abstract class AbstractGameControlImpl
extends java.lang.Object
implements InternalGameControl


Field Summary
protected  CollisionHandler collisionHandler
           
protected  Level level
           
protected  org.apache.log4j.Logger log
           
protected  java.util.Map<java.lang.Integer,com.golden.gamedev.object.Timer> platformCollisionTimers
          For every active player, a Timer is stored which is used to temporarily disable Ship/Platform collisions after take off, which likely occurs when the player is thrusting and rotating simultaneously.
 
Constructor Summary
AbstractGameControlImpl()
           
 
Method Summary
 void addFriction(Rectangle r, double friction)
          This method shall be used to change the friction matrix of the playground.
 void addGravity(Rectangle r, Vector gravity)
          This method shall be used to change the gravity matrix of the playground.
 void addStreamSpeed(Rectangle r, Vector stream)
          This method shall be used to change the stream speed matrix of the playground.
 void callScript(java.lang.String name, java.lang.Object... args)
           
 void cleanup()
           
 void finish()
          If this method is called, the currently played level will end.
 double getFrictionFor(MoaggGameObject object)
          Since the playground's friction may vary depending on the game object's position, this method shall be used to determine the object's current friction factor.
 Vector getGravityFor(MoaggGameObject object)
          Since the playground's gravity may vary depending on the game object's position, this method shall be used to determine the object's current gravity vector.
 Level getLevel()
           
 MoaggGameObject getObjectById(int id)
           
 java.util.List<MoaggGameObject> getObjects()
           
protected  com.golden.gamedev.object.Timer getPlatformCollisionTimer(int id)
           
 java.util.List<Platform> getPlatforms()
           
 Vector getStreamSpeedFor(MoaggGameObject object)
          Since the playground's stream speed may vary depending on the game object's position, this method shall be used to determine the object's current stream speed vector.
protected  void initScripting()
           
 boolean isBackgroundBetween(MoaggGameObject o1, MoaggGameObject o2)
           
 boolean isFinished()
           
 boolean isPlatformCollisionActive(Ship player)
          Called by the collision handlers to determine if a detected Ship/Platform collision has to be handled.
 void onObjectObjectCollision(MoaggGameObject object1, MoaggGameObject object2)
           
 void onObjectPlaygroundCollision(MoaggGameObject object)
           
 void resetPlatformCollisionTimer(Ship player)
          Called by the LandingHandler if a player takes off from a platform.
 void update(long elapsedTime)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface moagg.game.control.InternalGameControl
addParticle, addProjectile, getGhostsSpriteGroup, getPlayersSpriteGroup, getProjectilesSpriteGroup
 
Methods inherited from interface moagg.game.control.GameControl
addObjective, getPlayer, setPopUpText, setPopUpText, setStatusText
 

Field Detail

log

protected org.apache.log4j.Logger log

level

protected Level level

collisionHandler

protected CollisionHandler collisionHandler

platformCollisionTimers

protected java.util.Map<java.lang.Integer,com.golden.gamedev.object.Timer> platformCollisionTimers
For every active player, a Timer is stored which is used to temporarily disable Ship/Platform collisions after take off, which likely occurs when the player is thrusting and rotating simultaneously.

Constructor Detail

AbstractGameControlImpl

public AbstractGameControlImpl()
Method Detail

initScripting

protected void initScripting()

cleanup

public void cleanup()

update

public void update(long elapsedTime)
Specified by:
update in interface InternalGameControl

getLevel

public Level getLevel()
Specified by:
getLevel in interface InternalGameControl

addGravity

public void addGravity(Rectangle r,
                       Vector gravity)
Description copied from interface: GameControl
This method shall be used to change the gravity matrix of the playground.

Specified by:
addGravity in interface GameControl
Parameters:
r - A Rectangle indexing the tiles of the playground to change.
gravity - The gravity increment.

addStreamSpeed

public void addStreamSpeed(Rectangle r,
                           Vector stream)
Description copied from interface: GameControl
This method shall be used to change the stream speed matrix of the playground.

Specified by:
addStreamSpeed in interface GameControl
Parameters:
r - A Rectangle indexing the tiles of the playground to change.
stream - The stream speed increment.

addFriction

public void addFriction(Rectangle r,
                        double friction)
Description copied from interface: GameControl
This method shall be used to change the friction matrix of the playground.

Specified by:
addFriction in interface GameControl
Parameters:
r - A Rectangle indexing the tiles of the playground to change.
friction - The friction increment.

getGravityFor

public Vector getGravityFor(MoaggGameObject object)
Description copied from interface: GameControl
Since the playground's gravity may vary depending on the game object's position, this method shall be used to determine the object's current gravity vector.

Specified by:
getGravityFor in interface GameControl
Parameters:
object - The game object to determine the gravity for.
Returns:
The gravity vector of the given game object.

getStreamSpeedFor

public Vector getStreamSpeedFor(MoaggGameObject object)
Description copied from interface: GameControl
Since the playground's stream speed may vary depending on the game object's position, this method shall be used to determine the object's current stream speed vector.

Specified by:
getStreamSpeedFor in interface GameControl
Parameters:
object - The game object to determine the stream speed for.
Returns:
The stream speed vector of the given game object.

getFrictionFor

public double getFrictionFor(MoaggGameObject object)
Description copied from interface: GameControl
Since the playground's friction may vary depending on the game object's position, this method shall be used to determine the object's current friction factor.

Specified by:
getFrictionFor in interface GameControl
Parameters:
object - The game object to determine the friction for.
Returns:
The friction of the given game object.

getPlatforms

public java.util.List<Platform> getPlatforms()
Specified by:
getPlatforms in interface InternalGameControl

getObjects

public java.util.List<MoaggGameObject> getObjects()
Specified by:
getObjects in interface InternalGameControl

getObjectById

public MoaggGameObject getObjectById(int id)
Specified by:
getObjectById in interface GameControl
Parameters:
id - The id of the game object to return.
Returns:
The game object with the given id, or null if no such object exists.

isBackgroundBetween

public boolean isBackgroundBetween(MoaggGameObject o1,
                                   MoaggGameObject o2)
Specified by:
isBackgroundBetween in interface InternalGameControl
Returns:
true, if there's a clear line between the two game objects, else false.

getPlatformCollisionTimer

protected com.golden.gamedev.object.Timer getPlatformCollisionTimer(int id)

resetPlatformCollisionTimer

public void resetPlatformCollisionTimer(Ship player)
Description copied from interface: InternalGameControl
Called by the LandingHandler if a player takes off from a platform.

Specified by:
resetPlatformCollisionTimer in interface InternalGameControl
Parameters:
player - The player who took of a platform.

isPlatformCollisionActive

public boolean isPlatformCollisionActive(Ship player)
Description copied from interface: InternalGameControl
Called by the collision handlers to determine if a detected Ship/Platform collision has to be handled.

Specified by:
isPlatformCollisionActive in interface InternalGameControl
Parameters:
player - The player who collided with a Platform.
Returns:
true if the collision shall be handled, false if it shall be ignored.

onObjectPlaygroundCollision

public void onObjectPlaygroundCollision(MoaggGameObject object)
Specified by:
onObjectPlaygroundCollision in interface InternalGameControl

onObjectObjectCollision

public void onObjectObjectCollision(MoaggGameObject object1,
                                    MoaggGameObject object2)
Specified by:
onObjectObjectCollision in interface InternalGameControl

finish

public void finish()
Description copied from interface: GameControl
If this method is called, the currently played level will end.

Specified by:
finish in interface GameControl

isFinished

public boolean isFinished()

callScript

public void callScript(java.lang.String name,
                       java.lang.Object... args)
Specified by:
callScript in interface InternalGameControl


Copyright © 2008. All Rights Reserved.