View Javadoc

1   package nl.tudelft.pogamut.ut2004.agent.module.shooting.weapon;
2   
3   import nl.tudelft.pogamut.unreal.agent.module.shooting.AbstractWeaponShooting;
4   import nl.tudelft.pogamut.unreal.agent.module.shooting.util.FacingUtil;
5   import cz.cuni.amis.pogamut.ut2004.agent.module.sensomotoric.Weaponry;
6   import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.AgentInfo;
7   import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.WeaponPref;
8   import cz.cuni.amis.pogamut.ut2004.bot.command.ImprovedShooting;
9   import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
10  import cz.cuni.amis.pogamut.ut2004.communication.messages.UT2004ItemType;
11  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Player;
12  
13  /**
14   *
15   * <p>
16   * Module to work efficiently with the Redeemer.
17   * </p>
18   * 
19   * <p>
20   * TODO: Does not work yet. Redeemer never has ammo.
21   * </p>
22   * 
23   * @author mpkorstanje
24   * 
25   */
26  public class ReedeemerShooting extends AbstractWeaponShooting {
27  
28  	protected static final WeaponPref DEFAULT_WEAPON_PREF = new WeaponPref(UT2004ItemType.REDEEMER, false);
29  
30  	public ReedeemerShooting(UT2004Bot<?, ?, ?> agent, AgentInfo info, ImprovedShooting shoot, Weaponry weaponry) {
31  		super(agent, info, shoot, weaponry);
32  	}
33  
34  	@Override
35  	protected void shoot() {
36  
37  		// Wrong weapon, wait up.
38  		if (!isWeaponReady()) {
39  			return;
40  		}
41  
42  		// No target, no shoot.
43  		if (!hasTarget()) {
44  			shoot.stopShooting();
45  			return;
46  		}
47  
48  		if (!(target instanceof Player)) {
49  			shoot.shoot(target);
50  			return;
51  
52  		}
53  
54  		Player player = (Player) target;
55  
56  		// Target not visible, hold fire.
57  		if (!player.isVisible() || !FacingUtil.isFacing2D(info, target, FACING_ANGLE)) {
58  			shoot.stopShooting();
59  		} else {
60  			shoot.shoot(target);
61  		}
62  	}
63  
64  	@Override
65  	protected WeaponPref getDefaultWeaponPref() {
66  		return DEFAULT_WEAPON_PREF;
67  	}
68  
69  
70  	
71  
72  
73  }