Skip to content

Pellet Manager Reference

Alex Land edited this page Aug 16, 2018 · 3 revisions

This class handles creating and updating pellet locations. The global EventBus is used to handle data receipt asynchronously. Methods annotated with @Subscribe are used to handle relevant EventBus data.

Fields

private static final String TAG

Used for logging.

private PacMacroClient mApiClient

The API client for making requests. Results are published on the EventBus, received by the local methods annotated with @Subscribe.

private List<Pellet> mPelletList

The list of pellets, kept up to date in onPelletsReceived.

private InitializeCircleCallback mMapCallback

Callback passed in by the calling code used to create pellets on a map.

private GameController mGameController

The game loop. An action is registered to refresh pellet data via an API call.

Methods

PelletManager(PacMacroClient apiClient, InitializeCircleCallback mapCallback, GameController gameController)

Constructor. Each parameter is assigned to a field (see above), and a game loop action is registered to update pellets.

void onPelletsReceived(PelletReceivedEvent event)

An EventBus handler for when new pellet data is received. For each pellet received, the location, type, and visibility is extracted, the pellet is plotted on a map (via mMapCallback), it's visibility is set, and it is added to mPelletList.

void clearPellets()

Convenience method for clearing the circle (on the map) for each pellet in mPelletList. This method makes all the pellets disappear on the map.

Clone this wiki locally