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
6 import cz.cuni.amis.pogamut.ut2004.agent.module.sensomotoric.Weaponry;
7 import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.AgentInfo;
8 import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.WeaponPref;
9 import cz.cuni.amis.pogamut.ut2004.bot.command.ImprovedShooting;
10 import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
11 import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType;
12 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Player;
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 public class LigthningGunShooting extends AbstractWeaponShooting {
32
33 protected static final WeaponPref DEFAULT_WEAPON_PREF = new WeaponPref(ItemType.LIGHTNING_GUN, true);
34 public LigthningGunShooting(UT2004Bot<?, ?, ?> agent, AgentInfo info, ImprovedShooting shoot, Weaponry weaponry) {
35 super(agent, info, shoot, weaponry);
36 }
37
38 @Override
39 protected void shoot() {
40
41
42 if (!isWeaponReady()) {
43 return;
44 }
45
46
47 if (!hasTarget()) {
48 shoot.stopShooting();
49 return;
50 }
51
52 if (!(target instanceof Player)) {
53 shoot.shoot(target);
54 return;
55
56 }
57
58 Player player = (Player) target;
59
60
61 if (!player.isVisible() || !FacingUtil.isFacing2D(info, target, FACING_ANGLE)) {
62 shoot.stopShooting();
63 } else {
64 shoot.shoot(target);
65 }
66 }
67
68 @Override
69 protected WeaponPref getDefaultWeaponPref() {
70 return DEFAULT_WEAPON_PREF;
71 }
72
73
74 }