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,
java.lang.String type)
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, sendMessage, sendMessagepublic 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 game state from the JSON provided by the server and populates the map accordingly.
email - the user'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)
You need to implement this function.
getTeamScore in class GameteamId - the team ID (same kind of value as the TeamID constants)public boolean handleMessage(com.google.gson.JsonObject message,
java.lang.String type)
Since playerTargetVisit events are specific to target mode games, this method handles those. All other events are delegated to the superclass.
Some of this function is written for you, but there is a little piece for you to fill in.
handleMessage in class Gamemessage - JSON from the servertype - the update typepublic 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, a targetVisit update is sent to the server.
You need to implement this function, though much of the logic can be organized into the tryClaimTarget helper function below.
locationUpdated in class Gamelocation - a location FusedLocationProviderClient is reasonably confident about