|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.threerings.crowd.client.PlaceControllerDelegate
com.threerings.parlor.game.client.GameControllerDelegate
com.threerings.puzzle.client.PuzzleControllerDelegate
com.threerings.puzzle.drop.client.DropControllerDelegate
public abstract class DropControllerDelegate
Games that wish to make use of the drop puzzle services will need to create an extension of
this delegate class, customizing it for their particular game and then adding it via
PlaceController.addDelegate(com.threerings.crowd.client.PlaceControllerDelegate).
It handles logical actions for a puzzle game that generally consists of a two-dimensional board containing pieces, with new pieces either falling into the board as a "drop block", or rising into the bottom of the board in new piece rows.
Derived classes must implement getPieceVelocity(boolean) and evolveBoard().
Block-dropping puzzles will likely want to override createNextBlock(),
blockDidLand(), and getPieceDropLogic().
Board-rising puzzles will likely want to override getRiseVelocity(),
getRiseDistance(), getPieceDropLogic(), and boardDidRise().
| Field Summary | |
|---|---|
protected int |
_bhei
The board dimensions in pieces. |
protected DropBlockSprite |
_blocksprite
The drop block sprite associated with the landing block, if any. |
protected long |
_blockStamp
The timestamp used to keep track of when the drop block was removed so that we can fast-forward it when restored. |
protected int |
_bounceInterval
The duration of the bounce interval. |
protected int |
_bounceRow
The row at which we last bounced, or Integer.MIN_VALUE. |
protected long |
_bounceStamp
The time at which we last started bouncing, or 0. |
protected int |
_bwid
The board dimensions in pieces. |
protected PuzzleController |
_ctrl
Our puzzle controller. |
protected PuzzleContext |
_ctx
The puzzle context. |
protected DropBoard |
_dboard
The drop board. |
protected DropPanel |
_dpanel
The drop panel. |
protected DropSpriteObserver |
_dropMovedHandler
Used to listen to drop sprites and react to their move events. |
protected PieceDropper |
_dropper
The piece dropper used to drop pieces in the board if the puzzle chooses to make use of piece dropping functionality. |
protected DropBoardView |
_dview
The drop board view. |
protected com.threerings.media.animation.AnimationAdapter |
_evolveObserver
Used to evolve the board following the completion of animations. |
protected boolean |
_fastDrop
Whether the drop blocks are currently dropping quickly. |
protected int |
_risedist
The distance the board row travels in pixels. |
protected long |
_risesent
The time at which we last fired off a board rising event. |
protected long |
_risestamp
The time at which the last board rise began. |
protected float |
_risevel
The speed with which the board rises in pixels per millisecond. |
protected long |
_rpstamp
The time at which the board rise was paused. |
protected boolean |
_stable
Whether or not the board is currently stable. |
protected DropBoard.PieceOperation |
_updateBoardOp
A piece operation that will update piece sprites as board positions are updated. |
protected boolean |
_usedrop
Whether the game is using drop block functionality. |
protected boolean |
_userise
Whether the game is using board rising functionality. |
protected long |
_zipstamp
The time at which we were requested to start zipping. |
protected static float |
BOUNCE_FRACTION
Defines the distance of a piece that we allow to bounce before we land it. |
protected static int |
DEFAULT_RISE_DISTANCE
The default board row rising distance. |
protected static float |
DEFAULT_RISE_VELOCITY
The default board row rising velocity. |
static String |
END_DROP_BLOCK
The action command for ending dropping the block. |
static String |
MOVE_BLOCK_LEFT
The action command for moving the block to the left. |
static String |
MOVE_BLOCK_RIGHT
The action command for moving the block to the right. |
static String |
RAISE_ROW
The action command for raising the next rising row. |
protected static long |
RISE_INTERVAL
The delay in milliseconds between board rising intervals. |
static String |
ROTATE_BLOCK_CCW
The action command for rotating the block counter-clockwise. |
static String |
ROTATE_BLOCK_CW
The action command for rotating the block clockwise. |
static String |
START_DROP_BLOCK
The action command for starting to dropping the block. |
| Fields inherited from class com.threerings.puzzle.client.PuzzleControllerDelegate |
|---|
_puzobj |
| Fields inherited from class com.threerings.crowd.client.PlaceControllerDelegate |
|---|
_controller |
| Fields inherited from interface com.threerings.puzzle.drop.data.DropCodes |
|---|
DROP_MESSAGE_BUNDLE, DROP_STREAM, RISE_STREAM |
| Fields inherited from interface com.threerings.puzzle.drop.data.DropPieceCodes |
|---|
DROP_BLOCK_PIECE_COUNT, PIECE_NONE |
| Fields inherited from interface com.threerings.util.DirectionCodes |
|---|
CARDINAL_DIRECTIONS, CCW, CW, DIRECTION_COUNT, DOWN, EAST, EASTNORTHEAST, EASTSOUTHEAST, FINE_DIRECTION_COUNT, HORIZONTAL, LEFT, NONE, NORTH, NORTHEAST, NORTHNORTHEAST, NORTHNORTHWEST, NORTHWEST, RIGHT, SOUTH, SOUTHEAST, SOUTHSOUTHEAST, SOUTHSOUTHWEST, SOUTHWEST, UP, VERTICAL, WEST, WESTNORTHWEST, WESTSOUTHWEST |
| Fields inherited from interface com.threerings.puzzle.data.PuzzleCodes |
|---|
DEBUG_PUZZLE, DEFAULT_DIFFICULTY, PUZZLE_MESSAGE_BUNDLE |
| Fields inherited from interface com.threerings.presents.data.InvocationCodes |
|---|
ACCESS_DENIED, E_ACCESS_DENIED, E_INTERNAL_ERROR, GLOBAL_GROUP, INTERNAL_ERROR |
| Constructor Summary | |
|---|---|
DropControllerDelegate(PuzzleController ctrl,
DropLogic logic)
Creates a delegate with the specified drop game logic and controller. |
|
| Method Summary | |
|---|---|
protected void |
animationDidFinish(com.threerings.media.animation.Animation anim)
Called when an animation finishes doing its business. |
protected void |
applyDropSprite(DropSprite sprite,
int col,
int row)
Applies the pieces in the given sprite to the specified column and row in the board. |
protected void |
blockDidLand()
Called only for block-dropping puzzles when the drop block lands on something. |
protected void |
blockDidRotate(int dir)
Called when the drop block has rotated in the specified direction to allow derived classes to engage in any game-specific antics. |
protected void |
blockWillLand()
Called only for block-dropping puzzles when the drop block is about to land on something. |
protected void |
boardDidRise()
Called only for board-rising puzzles when the board has finished rising one row. |
protected void |
boardDidStabilize()
Called when the board has been fully evolved and is once again stable. |
protected void |
boardWillRise()
Called only for board-rising puzzles before effecting the rising of the board by one row. |
protected void |
bounceTimerExpired()
Called when the bounce timer expires. |
protected boolean |
canClearAction()
Delegates that wish to postpone action clearing can override this method to return false until such time as the action can be cleared. |
protected boolean |
canEvolveBoard()
Called to determine whether it is safe to evolve the board. |
protected boolean |
checkBlockLanded(String source,
boolean commit,
boolean atTop)
Checks whether the drop block can continue dropping and lands its pieces if not. |
protected boolean |
checkCanRise()
Called to determine whether or not rising a new row into the board is legal. |
protected boolean |
checkDropEndsGame()
Called by dropNextBlock() to determine whether the game should be ended rather than
dropping the next block because the board is filled and a new block cannot enter. |
protected void |
clearAction()
Clears out all of the action in the board; removes any drop block sprites, any pieces rising in the board, and resets the animation timestamps. |
protected DropBlockSprite |
createNextBlock()
Called only for block-dropping puzzles when it's time to create the next drop block. |
protected void |
dropNextBlock()
Handles creation and dropping of the next dropping block. |
protected boolean |
dropPieces()
Drops any pieces that need dropping and returns whether any pieces were dropped. |
protected abstract boolean |
evolveBoard()
Evolves the board to an unchanging state. |
void |
gameDidEnd()
Called when the game transitions to the GAME_OVER
state. |
Component |
getComponent()
|
protected PieceDropLogic |
getPieceDropLogic()
Returns the piece drop logic used to drop any pieces that need dropping in the board. |
protected PieceDropper |
getPieceDropper(PieceDropLogic logic)
Returns the piece dropper used to drop any pieces that need dropping in the board. |
protected abstract float |
getPieceVelocity(boolean fast)
Returns the drop sprite velocity to assign to a new drop sprite. |
protected int |
getRiseDistance()
Returns the distance in pixels that each board row will traverse when rising into place. |
protected float |
getRiseVelocity()
Returns the speed with which the next board row should rise into place, in pixels per millisecond. |
protected int |
getRotationType()
Returns the rotation type used by this drop game. |
boolean |
handleAction(ActionEvent action)
|
protected boolean |
handleBlockAction(ActionEvent action)
|
protected void |
handleDropBlock(boolean fast)
Handles drop block events. |
protected void |
handleDropSpriteMoved(DropSprite sprite,
long when,
int col,
int row)
Called when a drop sprite posts a piece moved event. |
protected void |
handleMoveBlock(int dir)
Handles block moved events. |
protected void |
handleRotateBlock(int dir)
Handles block rotation events. |
void |
init(CrowdContext ctx,
PlaceConfig config)
|
boolean |
needsPaint()
|
protected int[] |
peekNextPieces()
Take a peek at the next pieces. |
void |
setBoard(Board board)
Called when the puzzle controller sets up a new board for the player. |
void |
setRisingPaused(boolean paused)
Sets whether the board rising is paused. |
protected void |
startAction()
Starts up the action; tries evolving the board to get things going. |
protected void |
startBounceTimer(String source)
Called when a block lands. |
void |
tick(long tickStamp)
|
protected void |
unstabilizeBoard()
Derived classes should call this method whenever they change some board state that will require board evolution to restabilize the board. |
void |
updateSelfSummary()
Updates the player's own local board summary to reflect the local copy of the player's board which is likely to be more up to date than the server-side board from which all other player board summaries originate. |
void |
zipToNextRow()
Causes the board to zip quickly to the next row. |
| Methods inherited from class com.threerings.puzzle.client.PuzzleControllerDelegate |
|---|
canStartChatting, didLeavePlace, maybeClearAction, playerKnockedOut, setChatting, willEnterPlace |
| Methods inherited from class com.threerings.parlor.game.client.GameControllerDelegate |
|---|
gameDidStart, gameWasCancelled, gameWillReset |
| Methods inherited from class com.threerings.crowd.client.PlaceControllerDelegate |
|---|
mayLeavePlace |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String MOVE_BLOCK_LEFT
public static final String MOVE_BLOCK_RIGHT
public static final String ROTATE_BLOCK_CCW
public static final String ROTATE_BLOCK_CW
public static final String START_DROP_BLOCK
public static final String END_DROP_BLOCK
public static final String RAISE_ROW
protected PuzzleContext _ctx
protected PuzzleController _ctrl
protected DropPanel _dpanel
protected DropBoardView _dview
protected DropBoard _dboard
protected boolean _usedrop
protected boolean _userise
protected boolean _stable
protected int _bwid
protected int _bhei
protected int _risedist
protected float _risevel
protected DropBlockSprite _blocksprite
protected PieceDropper _dropper
protected long _rpstamp
protected long _risestamp
protected long _risesent
protected long _zipstamp
protected int _bounceInterval
protected long _bounceStamp
protected int _bounceRow
Integer.MIN_VALUE.
protected long _blockStamp
protected boolean _fastDrop
protected com.threerings.media.animation.AnimationAdapter _evolveObserver
protected DropSpriteObserver _dropMovedHandler
protected DropBoard.PieceOperation _updateBoardOp
protected static final float DEFAULT_RISE_VELOCITY
protected static final int DEFAULT_RISE_DISTANCE
protected static final long RISE_INTERVAL
protected static final float BOUNCE_FRACTION
| Constructor Detail |
|---|
public DropControllerDelegate(PuzzleController ctrl,
DropLogic logic)
| Method Detail |
|---|
public void init(CrowdContext ctx,
PlaceConfig config)
init in class PlaceControllerDelegateprotected float getRiseVelocity()
protected int getRiseDistance()
protected void startAction()
startAction in class PuzzleControllerDelegateprotected boolean canClearAction()
PuzzleControllerDelegatePuzzleControllerDelegate.maybeClearAction() when conditions become such that they would once again allow
action to be cleared.
canClearAction in class PuzzleControllerDelegateprotected void clearAction()
clearAction in class PuzzleControllerDelegatepublic void gameDidEnd()
GameControllerDelegateGAME_OVER
state. This happens when the game reaches some end condition by
normal means (is not cancelled or aborted).
gameDidEnd in class GameControllerDelegatepublic boolean handleAction(ActionEvent action)
handleAction in class PlaceControllerDelegatepublic void setBoard(Board board)
PuzzleControllerDelegate
setBoard in class PuzzleControllerDelegateboard - the newly initialized and ready-to-go board.protected boolean handleBlockAction(ActionEvent action)
protected void handleMoveBlock(int dir)
protected void handleRotateBlock(int dir)
protected void blockDidRotate(int dir)
protected int getRotationType()
DropBoard.RADIAL_ROTATION
or DropBoard.INPLACE_ROTATION.
protected void handleDropBlock(boolean fast)
protected abstract float getPieceVelocity(boolean fast)
protected void dropNextBlock()
protected boolean checkDropEndsGame()
dropNextBlock() to determine whether the game should be ended rather than
dropping the next block because the board is filled and a new block cannot enter. If true
is returned, the drop controller assumes that the derived class will have ended or reset
the game as appropriate and will simply abandon its attempt to drop the next block.
protected DropBlockSprite createNextBlock()
null if it
was not.
protected int[] peekNextPieces()
protected void handleDropSpriteMoved(DropSprite sprite,
long when,
int col,
int row)
protected void applyDropSprite(DropSprite sprite,
int col,
int row)
protected boolean canEvolveBoard()
protected abstract boolean evolveBoard()
dropPieces(), piece destruction, and/or piece joining), this is where that process
should be effected.
When no further evolution is possible and the board has stabilized this method should
return false to indicate that such action should be taken. That will result in a follow-up
call to boardDidStabilize() (assuming that the action was not cleared prior to the
final stabilization of the board).
protected void unstabilizeBoard()
protected void boardDidStabilize()
public void updateSelfSummary()
protected void animationDidFinish(com.threerings.media.animation.Animation anim)
super.animationDidFinish().
protected boolean checkBlockLanded(String source,
boolean commit,
boolean atTop)
commit - if true, the block landing is committed, if false, it is only checked, not
committed.atTop - whether the block sprite is to be treated as being at the top of its current
row.protected void blockWillLand()
protected void blockDidLand()
protected void startBounceTimer(String source)
protected void bounceTimerExpired()
protected boolean dropPieces()
evolveBoard() implementation, and must also override getPieceDropLogic() to
provide their game-specific piece dropper implementation.
protected PieceDropLogic getPieceDropLogic()
dropPieces() must implement this method
and return a reference to their game-specific piece dropper implementation.
protected PieceDropper getPieceDropper(PieceDropLogic logic)
public void tick(long tickStamp)
tick in interface com.threerings.media.FrameParticipantpublic Component getComponent()
getComponent in interface com.threerings.media.FrameParticipantpublic boolean needsPaint()
needsPaint in interface com.threerings.media.FrameParticipantpublic void setRisingPaused(boolean paused)
public void zipToNextRow()
protected boolean checkCanRise()
protected void boardWillRise()
super.boardWillRise().
protected void boardDidRise()
super.boardDidRise().
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||