|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.cuni.pogamut.Client.AgentInventory
public class AgentInventory
AgentInventory serves to keep info about the weapons agent is carrying it provides usefull methods which can be used to determine suitability of visible ammo or to able to switch among possesed weapons
Some profiling should take place here - don't know which operation will be the most used, so I tried to KISS - "keep it simple and stupid":)
Field Summary | |
---|---|
private int |
currentWeapon
|
private java.util.ArrayList<AddAmmo> |
extraAmmo
|
private static int |
melee
|
private java.util.logging.Logger |
platformLog
|
private java.util.ArrayList<AddWeapon> |
weapons
|
Constructor Summary | |
---|---|
AgentInventory(AgentBody body,
java.util.logging.Logger logger)
body is necessary for registering of listeners for events logger is just to log to the same file |
Method Summary | |
---|---|
protected void |
addWeapon(AddWeapon newWeapon)
adds new Weapon to weapons - after AIN GB message if the bot collected any extra ammo for the weapon, add it to the weapon.currentAmmo |
protected void |
addWeaponToWeapons(AddWeapon newWeapon)
Adds newWeapon ammo to the ammo of weapon of the same type in the inventory if the weapon was the first agent got (at the game start), set it as current |
boolean |
anyLoaded()
|
protected void |
collectAmmo(AddAmmo ammo)
Method to set takes care about picking-up an ammo |
java.util.ArrayList<AddWeapon> |
getAllWeapons()
provides an access to weapons NOT SYNCHRONIZED!!! |
AddWeapon |
getBetterWeapon(Triple from,
Triple to)
returns null, if bot has no weapon, that is better than the one he already holds according to the distance from the target returns better weapon, if there is any loaded NOTE! |
java.util.ArrayList<AddWeapon> |
getCopyOfAllWeapons()
get copies of weapons - to handle them by user |
AddWeapon |
getCurrentWeapon()
return AddWeapon with the weapon agent is currently holding |
AddWeapon |
getWeapon()
get any loaded weapon from loaded weapons |
AddWeapon |
getWeapon(boolean isMelee)
get weapon of desired type (melee/ranged) from loaded weapons can't give you Shield Gun! |
AddWeapon |
getWeaponOfType(ItemType type)
|
boolean |
hasWeaponOfType(ItemType type)
|
protected void |
changeWeapon(ChangedWeapon change)
when bot changes weapon - message about change arrives, change index of current weapon |
int |
numberOfLoadedWeapons()
returns number of loaded weapons |
int |
numberOfWeapons()
returns number of weapons |
private void |
processSelf(Self selfMsg)
update current ammo in the current weapon update current weapon - like when agent thrown it away everything is according to info in self |
void |
receiveMessage(RcvMsgEvent e)
listener for events - handels incomming messages ADD_AMMO - add collected ammo to inventory ADD_WEAPON - add weapon to inventory ADD_SPECIAL - nothing yet, place to add whatever developper needs SELF - correction of current ammo and current weapon - when bot fires it is no other way to find out how much ammo he has left CHANGED_WEAPON - bot changed weapon - reflect it to inventory |
void |
restartInventory()
restarts inventory after agent's death |
boolean |
suitableAmmo(Ammo ammo)
To test, whether Ammo of type is suitable for one of collected weapons it is not AddAmmo, because we want to know it for ammo which is still on the floor |
java.lang.String |
toString()
|
protected void |
zeroAmmo(int ID)
zero ammo - set weapon to unloaded |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private java.util.ArrayList<AddWeapon> weapons
private java.util.ArrayList<AddAmmo> extraAmmo
private java.util.logging.Logger platformLog
private int currentWeapon
private static int melee
Constructor Detail |
---|
public AgentInventory(AgentBody body, java.util.logging.Logger logger)
body
- logger
- Method Detail |
---|
public void restartInventory()
public boolean anyLoaded()
protected void addWeapon(AddWeapon newWeapon)
newWeapon
- protected void addWeaponToWeapons(AddWeapon newWeapon)
newWeapon
- public AddWeapon getWeapon(boolean isMelee)
can't give you Shield Gun! (not considered as a weapon)
isMelee
-
public AddWeapon getWeapon()
protected void zeroAmmo(int ID)
ID
- protected void collectAmmo(AddAmmo ammo)
ammo
- public boolean suitableAmmo(Ammo ammo)
ammo
-
protected void changeWeapon(ChangedWeapon change)
change
- public AddWeapon getCurrentWeapon()
public java.lang.String toString()
toString
in class java.lang.Object
private void processSelf(Self selfMsg)
public void receiveMessage(RcvMsgEvent e)
receiveMessage
in interface RcvMsgListener
public boolean hasWeaponOfType(ItemType type)
public AddWeapon getWeaponOfType(ItemType type)
public int numberOfWeapons()
public int numberOfLoadedWeapons()
public AddWeapon getBetterWeapon(Triple from, Triple to)
returns weapon with the lowest effectiveDist big enough to shoot at player - so for close player picks up flak cannon:)
from
- to
-
public java.util.ArrayList<AddWeapon> getAllWeapons()
public java.util.ArrayList<AddWeapon> getCopyOfAllWeapons()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |