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