|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--nankin.zheng.gatem.model.GameScheduler
A game scheduler is a container holding several game containers. It contains methods to create thread for the game, update each game container during the game loop, control the game status and pass game events among different game containers.
Field Summary | |
static int |
CONTAINER_ACTIVE
|
static int |
CONTAINER_NOT_ACTIVE
|
protected java.util.Vector |
containers
|
protected CacheContainer |
displayer
|
protected Env |
env
|
static int |
GAME_EXIT
|
static int |
GAME_FAIL
|
static int |
GAME_OVER
|
static int |
GAME_PASS
|
static int |
GAME_PAUSE
|
static int |
GAME_PREFACE
|
static int |
GAME_RUNNING
|
static int |
GAME_STAGE_INTRO
|
protected int |
gameStatus
|
Constructor Summary | |
GameScheduler(Env environ,
CacheContainer disp)
Constructor. |
Method Summary | |
void |
addGameContainer(GameContainer gcont)
Add a game container. |
void |
broadcastGameEvent(GameEvent gevt)
Broadcast game event to all the active game containers. |
protected void |
gameActivity(int sts)
executed in a loop while game status is unrecognizable. |
protected void |
gameFail()
executed in a loop during GAME_FAIL. |
protected void |
gameOver()
executed in a loop during GAME_OVER. |
protected void |
gamePass()
executed in a loop during GAME_PASS. |
protected void |
gamePause()
executed in a loop during GAME_PAUSE. |
protected void |
gamePreface()
executed in a loop during GAME_PREFACE While GAME_PREFACE, a preface of the game will be displayed. |
protected void |
gameRunning()
executed in a loop during GAME_RUNNING. |
protected void |
gameStageIntro()
executed in a loop during GAME_STAGE_INTRO While GAME_STAGE_INTRO, a brief introduction of this stage will be displayed. |
int |
getGameStatus()
Get game status. |
protected boolean |
hasNextStage()
Whether has next stage. |
protected void |
loadNextStage()
Load next stage into all its containers. |
void |
readStageScript(java.lang.String fname)
Read stage script. |
protected abstract void |
receiveGameEvent(GameEvent gevt)
Receive game event itself. |
protected void |
reloadStage()
Reload the current stage into all its containers. |
void |
run()
Implements Runnable |
void |
startGame()
Start game. |
void |
testInitialization()
Whether this game scheduler is initialized properly. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected Env env
protected CacheContainer displayer
protected java.util.Vector containers
protected int gameStatus
public static final int CONTAINER_ACTIVE
public static final int CONTAINER_NOT_ACTIVE
public static final int GAME_EXIT
public static final int GAME_OVER
public static final int GAME_PREFACE
public static final int GAME_STAGE_INTRO
public static final int GAME_RUNNING
public static final int GAME_PAUSE
public static final int GAME_PASS
public static final int GAME_FAIL
Constructor Detail |
public GameScheduler(Env environ, CacheContainer disp) throws GameException
environ
- game environmentdisp
- displayer
java.lang.NullPointerException
- if environ or disp is null.
GameException
- may be thrown out by its subclasses.Method Detail |
public int getGameStatus()
public void addGameContainer(GameContainer gcont)
gcont
- GameContainer to be added.
java.lang.NullPointerException
- if gcont is null.public void testInitialization() throws GameException
GameException
- if is not initialized properly.public void broadcastGameEvent(GameEvent gevt) throws GameException
gevt
- GameEvent to be broadcasted.
java.lang.NullPointerException
- if gevt is null
GameException
- may be thrown out by GameContainer.broadcaseGameEvent().protected abstract void receiveGameEvent(GameEvent gevt) throws GameException
gevt
- GameEvent received
GameException
- may be thrown out by its subclasses.protected void gamePreface() throws GameException
GameException
protected void gameStageIntro() throws GameException
GameException
protected void gameRunning() throws GameException
GameException
protected void gamePause() throws GameException
GameException
protected void gamePass() throws GameException
GameException
protected void gameFail() throws GameException
GameException
protected void gameOver() throws GameException
GameException
protected void gameActivity(int sts) throws GameException
GameException
public void run()
run
in interface java.lang.Runnable
public void startGame()
This method creates a thread and start the game.
protected void loadNextStage() throws GameException
GameException
protected void reloadStage() throws GameException
GameException
protected boolean hasNextStage() throws GameException
GameException
public void readStageScript(java.lang.String fname) throws GameException
GameException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |