Exemple #1
0
 void handleFire(Person person, Room room) {
   if (person.isFire()) {
     AbstractWeapon weapon = person.getWeapon();
     long now = System.currentTimeMillis();
     if (!person.isReload() && weapon.getCurrentClip() <= 0) {
       if (weapon.getTotalClip() > 0) {
         person.setIsReload(true);
         person.setReloadCooldown(now + person.getWeapon().getReloadTimeout());
       }
     } else if (!person.isReload()
         && weapon.getCurrentClip() > 0
         && person.getShotCooldown() < now) {
       fire(person, room);
     }
   }
 }
Exemple #2
0
 private void handleWeaponPick(Person player, AbstractWeapon weapon) {
   for (AbstractWeapon personHaving : player.getWeaponList()) {
     if (personHaving.getClass().equals(weapon.getClass())) {
       personHaving.setTotalClip(personHaving.getTotalClip() + weapon.getTotalClip());
       personHaving.setCurrentClip(personHaving.getClipSize());
       if (player.isReload() && personHaving == player.getWeapon()) {
         player.setReload(false);
         player.setReloadCooldown(0);
       }
       if (personHaving.getTotalClip() > personHaving.getMaxClip()) {
         personHaving.setTotalClip(weapon.getMaxClip());
       }
       return;
     }
   }
   player.getWeaponList().add(weapon);
 }