1 package nl.tudelft.pogamut.ut2004.agent.module.shooting.weapon;
2
3 import nl.tudelft.pogamut.ut2004.agent.module.shooting.AbstractWeaponShooting;
4 import nl.tudelft.pogamut.ut2004.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.ItemType;
11 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Player;
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 public class ReedeemerShooting extends AbstractWeaponShooting {
27
28 protected static final WeaponPref DEFAULT_WEAPON_PREF = new WeaponPref(ItemType.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
38 if (!isWeaponReady()) {
39 return;
40 }
41
42
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
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 }