Mental Map
The MentalMap
, stores all the information related to the game elements, such as players, targets and weapons. When some of these elements change, for instance, after a player has been hit, it notifies all the MentalMapEventListerners
subscribed with a new event.
The main members of this class are:
getTargets()
: obtain the targets stored in theMentalMap
.getPlayers()
: obtain the players stored in theMentalMap
.getTarget()
: obtain a certain target stored in theMentalMap
.getPlayer()
: obtain a certain player stored in theMentalMap
.getMyself()
: Get the player corresponding to the user.
addWeapon(Weapon weapon)
: stores a new weapon on theMentalMap
.getCurrentWeapon()
: obtain the selected weapon.shoot()
: perform all the actions to be carried out when the user shoots (sound, update players, etc).reload()
: perform all the actions to be carried out when the user reloads (sound, update weapons, etc).
updatePlayers()
: updates the players' data stored in theMentalMap
. The current implementation just replaces the players inside theMentalMap
by the new players received from the server.updateTargets()
: update the targets stored in theMentalMap
. If a target previously detected is no longer present in the new detections, decreases the belief value until reaching 0. Then, it deletes that target.respawn()
: restores the health of current player (and does more stuff if needed).
addMentalMapEventListener()
: registers aMentalMapEventListener
that will be notified when new image events are received.removeMentalMapEventListeners()
: unsuscribes all the registered listeners, and they will not be notified until they are registered again.
onDataArrived()
: this function is called to notify theMentalMap
that new data has arrived from the server and the stored data has to be updated.