com.tootsville.game
Class ShadowTree

java.lang.Object
  extended by org.starhope.appius.game.GameEvent
      extended by com.tootsville.game.ShadowTree
All Implemented Interfaces:
Comparable<Object>, RoomListener, AcceptsMetronomeTicks, HasName

public class ShadowTree
extends GameEvent

Author:
ewinkelman

Field Summary
private  org.starhope.appius.geometry.Polygon branchArea
          Special area on the branch to cause it to break
private  int branchState
          If the branch is in the down position
private  org.starhope.appius.geometry.Polygon brokenBranchArea
          Special area for when the branch is broken
private  double hitpoints
          Tree branch hit points
private  org.starhope.appius.geometry.Rectangle landing
          Landing area for falling toots
private  long lastShake
          The last time that the branch was shaken
private  Room room
          Soccer field room object
private  ConcurrentHashMap<AbstractUser,Double> userHits
          User hits so that one user can't just spam jump
 
Fields inherited from class org.starhope.appius.game.GameEvent
freezeTag, gameCode, gameState, players, rooms, scores, scoreWatchRooms
 
Constructor Summary
ShadowTree(Zone z)
          WRITEME brpocock@star-hope.org Sep 28, 2010
 
Method Summary
 void acceptGameAction(AbstractUser u, org.json.JSONObject action)
          Broadcast message of a game action taking place
 void acceptOutOfBandMessage(AbstractUser sender, Room room, org.json.JSONObject body)
          Accept an out-of-band communications packet that was broadcast to a room in which this Listener is listening.
 void acceptPublicMessage(AbstractUser from, String message)
          Accept a public chat message.
 void acceptUserAction(Room r, AbstractUser u)
          User actions (go/do actions) propagate through this channel.
 void destroySelf()
          Destroy this event — during Zone shutdown usually
 String getGameEventPrefix()
          Get the prefix to be applied to event types for this game
 String getName()
          Return a user-visible, unique name for this class.
private  void shakeLimb()
          Shakes the limb every two seconds max
 void tick(long currentTime, long deltaTime)
          This method is called periodically from the metronome thread.
 
Methods inherited from class org.starhope.appius.game.GameEvent
acceptCommand, acceptCommand, acceptGameStateChange, acceptObjectJoinRoom, acceptObjectPartRoom, acceptPublicMessage, acceptUserVariableUpdate, changeGameState, compareTo, decrementScore, disconnect, equals, equals, getCountdownDuration, getEveryone, getGameCode, getGameDuration, getGameShortName, getLeaderBonus, getPlayers, getRoom, getRooms, getScoreWatchRooms, getSpectators, getTimer, getZone, hashCode, incrementScore, propagateGameStateChange, resetPlayers, sendEndEvents, sendStartEvents, toString, updateRoomVars, updateScore, updateScores
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

branchArea

private final transient org.starhope.appius.geometry.Polygon branchArea
Special area on the branch to cause it to break


branchState

private transient int branchState
If the branch is in the down position


brokenBranchArea

private final transient org.starhope.appius.geometry.Polygon brokenBranchArea
Special area for when the branch is broken


hitpoints

private transient double hitpoints
Tree branch hit points


landing

private final transient org.starhope.appius.geometry.Rectangle landing
Landing area for falling toots


lastShake

private transient long lastShake
The last time that the branch was shaken


room

private final transient Room room
Soccer field room object


userHits

private final transient ConcurrentHashMap<AbstractUser,Double> userHits
User hits so that one user can't just spam jump

Constructor Detail

ShadowTree

public ShadowTree(Zone z)
           throws NotFoundException,
                  GameLogicException
WRITEME brpocock@star-hope.org Sep 28, 2010

Parameters:
z - Zone in which tree is placed
Throws:
NotFoundException - WRITEME
GameLogicException - WRITEME
Method Detail

acceptGameAction

public void acceptGameAction(AbstractUser u,
                             org.json.JSONObject action)
Description copied from interface: RoomListener
Broadcast message of a game action taking place

Parameters:
u - the sender
action - The game action. The verb is in action.getString("action").
See Also:
RoomListener.acceptGameAction(org.starhope.appius.user.AbstractUser, org.json.JSONObject)

acceptOutOfBandMessage

public void acceptOutOfBandMessage(AbstractUser sender,
                                   Room room,
                                   org.json.JSONObject body)
Description copied from interface: RoomListener
Accept an out-of-band communications packet that was broadcast to a room in which this Listener is listening.

Parameters:
sender - The sender of the OOB message
room - The room in which the OOB message is being broadcast
body - A JSON object containing the OOB message. The contents of this message are not constrained.
See Also:
RoomListener.acceptOutOfBandMessage(org.starhope.appius.user.AbstractUser, org.starhope.appius.game.Room, org.json.JSONObject)

acceptPublicMessage

public void acceptPublicMessage(AbstractUser from,
                                String message)
Description copied from interface: RoomListener
Accept a public chat message. This prototype does not specify the room, on the (potentially invalid) assumption that the room listener doesn't care from which room the speech was made.

Parameters:
from - The speaker
message - The spoken text or /emote
See Also:
RoomListener.acceptPublicMessage(org.starhope.appius.user.AbstractUser, java.lang.String)

acceptUserAction

public void acceptUserAction(Room r,
                             AbstractUser u)
Description copied from interface: RoomListener
User actions (go/do actions) propagate through this channel.

Parameters:
r - the room in which the user is taking an action
u - the user taking an action
See Also:
RoomListener.acceptUserAction(org.starhope.appius.game.Room, org.starhope.appius.user.AbstractUser)

destroySelf

public void destroySelf()
Description copied from class: GameEvent
Destroy this event — during Zone shutdown usually

Overrides:
destroySelf in class GameEvent
See Also:
GameEvent.destroySelf()

getGameEventPrefix

public String getGameEventPrefix()
Description copied from class: GameEvent
Get the prefix to be applied to event types for this game

Specified by:
getGameEventPrefix in class GameEvent
Returns:
the string prefix used to find event types for this game
See Also:
GameEvent.getGameEventPrefix()

getName

public String getName()
Description copied from interface: HasName
Return a user-visible, unique name for this class. This name may not necessarily be globally unique, but must be unique across all objects of this class. For example, having both a User and a Zone named “Lightning” is acceptable, but there may not be two users with the same name.

Returns:
a user-visible string name for this instance
See Also:
HasName.getName()

shakeLimb

private void shakeLimb()
Shakes the limb every two seconds max


tick

public void tick(long currentTime,
                 long deltaTime)
          throws UserDeadException
Description copied from interface: AcceptsMetronomeTicks
This method is called periodically from the metronome thread. To save computation, it receives both the current time since epoch in milliseconds at the start of the global tick propagation, and the delta time since the previous metronome tick.

Specified by:
tick in interface AcceptsMetronomeTicks
Overrides:
tick in class GameEvent
Parameters:
currentTime - Time since epoch at the start of the global metronome propagation, as per System.currentTimeMillis()
deltaTime - Delta-time in milliseconds since the prior global metronome tick
Throws:
UserDeadException - if a user has died during this tick
See Also:
GameEvent.tick(long, long)