public final class TargetGame extends Game
Constructor and Description |
---|
TargetGame(java.lang.String email,
com.google.android.gms.maps.GoogleMap map,
com.neovisionaries.ws.client.WebSocket webSocket,
com.google.gson.JsonObject fullState,
android.content.Context context)
Creates a game in target mode.
|
Modifier and Type | Method and Description |
---|---|
int |
getTeamScore(int teamId)
Gets a team's score in this target mode game.
|
boolean |
handleMessage(com.google.gson.JsonObject message)
Processes an update from the server.
|
void |
locationUpdated(com.google.android.gms.maps.model.LatLng location)
Called when the user's location changes.
|
getContext, getEmail, getMap, getMyTeam, getWinningTeam, sendMessage
public TargetGame(java.lang.String email, com.google.android.gms.maps.GoogleMap map, com.neovisionaries.ws.client.WebSocket webSocket, com.google.gson.JsonObject fullState, android.content.Context context)
Loads the existing game state from the JSON provided by the server into instance variables and populates the map accordingly.
email
- the player's emailmap
- the Google Maps control to render towebSocket
- the websocket to send updates tofullState
- the "full" update from the servercontext
- the Android UI contextpublic int getTeamScore(int teamId)
getTeamScore
in class Game
teamId
- the team IDpublic boolean handleMessage(com.google.gson.JsonObject message)
Since playerTargetVisit events are specific to target mode games, this method handles those. All other events are delegated to the superclass.
handleMessage
in class Game
message
- JSON from the server (the "type" property indicates the update type)public void locationUpdated(com.google.android.gms.maps.model.LatLng location)
Target mode games detect whether the player is within the game's proximity threshold of a target. Capture is possible if the target is unclaimed and the new line segment from the player's previously captured target (if any) does not intersect any other line segment. If a target is captured, this method sends a targetVisit update to the server.
locationUpdated
in class Game
location
- the player's most recently known location