1 package nl.tudelft.pogamut.ut2004.agent.module.shooting.weapon;
2
3 import nl.tudelft.pogamut.unreal.agent.module.shooting.AbstractWeaponShooting;
4 import cz.cuni.amis.pogamut.ut2004.agent.module.sensomotoric.Weaponry;
5 import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.AgentInfo;
6 import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.WeaponPref;
7 import cz.cuni.amis.pogamut.ut2004.bot.command.ImprovedShooting;
8 import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
9 import cz.cuni.amis.pogamut.ut2004.communication.messages.UT2004ItemType;
10 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Player;
11
12 public class MinigunShooting extends AbstractWeaponShooting {
13
14 protected static final WeaponPref DEFAULT_WEAPON_PREF = new WeaponPref(UT2004ItemType.MINIGUN, true);
15
16 public MinigunShooting(UT2004Bot<?, ?, ?> agent, AgentInfo info, ImprovedShooting shoot, Weaponry weaponry) {
17 super(agent, info, shoot, weaponry);
18 }
19
20 @Override
21 protected void shoot() {
22
23
24 if (!isWeaponReady()) {
25 return;
26 }
27
28
29 if (!hasTarget()) {
30 shoot.stopShooting();
31 return;
32 }
33
34 if (!(target instanceof Player)) {
35 shoot.shoot(target);
36 return;
37 }
38
39 Player player = (Player) target;
40
41
42
43 if (!player.isVisible()) {
44 shoot.stopShooting();
45 return;
46 } else {
47 shoot.shoot(weaponPref, target);
48 }
49 }
50
51 @Override
52 protected WeaponPref getDefaultWeaponPref() {
53 return DEFAULT_WEAPON_PREF;
54 }
55
56 }