|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectserver.brickblock.fwimpl.BBEventHandler
public class BBEventHandler
Thread that is responsible for generating traps and power up objects, as well as player positions on game initiation. In addition, this class is responsible for handling game events.
Field Summary | |
---|---|
static int |
POWERUP_DURATION_SECS
|
static int |
POWERUP_INTERVAL_SECS
|
Constructor Summary | |
---|---|
BBEventHandler(BBSession session)
Creates the BBEventHandler object. |
Method Summary | |
---|---|
void |
checkSettings()
Checks if the game has timed out, or if the number of players connected to the session is too large. |
void |
fireEventOccured(AbstractPlayer player)
Not implemented. |
void |
fireEventOccured(BBPlayer player,
Event event,
java.lang.Object[] values)
Called when a game related event has occurred. |
void |
firePowerupAdded(Powerup powerup)
Called when a power up object has been generated. |
void |
firePowerupRemoved(Powerup powerup)
Called when a power up object has been removed. |
void |
generatePositions(java.util.List<BBPlayer> players)
Generates random positions for the players given in the list. |
static int[] |
generateRandomPosition(int screenWidth,
int screenHeight)
Generates a random position within the specified bounds. |
boolean |
isReady()
Checks whether the thread has completed its pre-game calculations and is ready to start a game. |
static boolean |
positionIsOccupied(int[] position,
java.util.List<BBPlayer> players,
int playerToCheck)
Checks if a given position is occupied by any players. |
void |
run()
The loop where power up objects are created, and the players' power up objects are controlled. |
void |
setSession(BBSession session)
Sets this thread's session. |
void |
stop()
Stops the thread. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int POWERUP_INTERVAL_SECS
public static final int POWERUP_DURATION_SECS
Constructor Detail |
---|
public BBEventHandler(BBSession session)
BBEventHandler
object. Initialises
the power up list and generates the trap position.
session
- This thread's session.Method Detail |
---|
public void run()
run
in interface java.lang.Runnable
public void checkSettings()
checkSettings
in interface EventHandler<BBPlayer,BBSession>
public void fireEventOccured(AbstractPlayer player)
player
- Not used.public void firePowerupAdded(Powerup powerup)
powerup
- The new power up object.public void firePowerupRemoved(Powerup powerup)
powerup
- The power up that is to be removed.public void setSession(BBSession session)
setSession
in interface EventHandler<BBPlayer,BBSession>
session
- This thread's session.public void stop()
stop
in interface EventHandler<BBPlayer,BBSession>
public void fireEventOccured(BBPlayer player, Event event, java.lang.Object[] values)
fireEventOccured
in interface EventHandler<BBPlayer,BBSession>
player
- The player that caused the event.event
- The event.values
- Values related to the event.public void generatePositions(java.util.List<BBPlayer> players)
players
- The list of players.public static boolean positionIsOccupied(int[] position, java.util.List<BBPlayer> players, int playerToCheck)
position
- The position to check.players
- The list of relevant players.playerToCheck
- The last position in the list to check.
public static int[] generateRandomPosition(int screenWidth, int screenHeight)
screenWidth
- The maximum x-position.screenHeight
- The maximum y-position.
public boolean isReady()
isReady
in interface EventHandler<BBPlayer,BBSession>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |