public class SimpleLevel extends Object implements Level, Serializable, com.sun.sgs.app.ChannelListener
Level that doesn't try to
do anything fancy with managing the internal state. It uses a
LevelBoard to track eveything on the level,NAME_PREFIX| Constructor and Description |
|---|
SimpleLevel(String levelName,
String gameName)
Creates a
SimpleLevel. |
| Modifier and Type | Method and Description |
|---|---|
void |
addCharacter(CharacterManager mgr)
Adds a character to this level at some random point.
|
boolean |
addCharacter(CharacterManager mgr,
int startX,
int startY)
Adds a character to this level at the given location.
|
void |
addItem(Item item)
Adds an item to this level at some random position.
|
void |
addItem(Item item,
int startX,
int startY)
Adds an item to this level at the given position.
|
Board |
getBoardSnapshot()
Returns a snapshot (ie, static) view of the level.
|
String |
getName()
Returns the name of this level.
|
boolean |
move(CharacterManager mgr,
KeyMessages.Type direction)
Tries to move the given character in the given direction
|
void |
receivedMessage(com.sun.sgs.app.Channel channel,
com.sun.sgs.app.ClientSession sender,
ByteBuffer message) |
void |
removeCharacter(CharacterManager mgr)
Removes a character from the level.
|
void |
setBoard(LevelBoard board)
Sets the
Board that maintains state for this level. |
boolean |
take(CharacterManager mgr)
Tries to take items at the character's current location.
|
public void setBoard(LevelBoard board)
Board that maintains state for this level.
Typically this only called once, shortly after the Level
is created.board - the Board used by this Levelpublic String getName()
public void receivedMessage(com.sun.sgs.app.Channel channel,
com.sun.sgs.app.ClientSession sender,
ByteBuffer message)
receivedMessage in interface com.sun.sgs.app.ChannelListenerpublic void addCharacter(CharacterManager mgr)
addCharacter in interface Levelmgr - the CharacterManager who's
Character is joining this
Levelpublic boolean addCharacter(CharacterManager mgr, int startX, int startY)
addCharacter in interface Levelmgr - the CharacterManager who's
Character is joining this LevelstartX - the starting x-coordinatestartY - the starting y-coordinatepublic void removeCharacter(CharacterManager mgr)
removeCharacter in interface Levelmgr - the CharacterManager who's
Character is joining this Levelpublic void addItem(Item item)
public void addItem(Item item, int startX, int startY)
public Board getBoardSnapshot()
SnapshotBoard so it can be shared with a client.getBoardSnapshot in interface Levelpublic boolean move(CharacterManager mgr, KeyMessages.Type direction)
public boolean take(CharacterManager mgr)
Copyright © 2013. All Rights Reserved.