Пример #1
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);
 }
Пример #2
0
 public void changeWeapon(Person person, Integer weaponCode) {
   if (person.isReload()) {
     return;
   }
   String weaponTitle = "";
   switch (weaponCode) {
     case 1:
       weaponTitle = "knife";
       break;
     case 2:
       weaponTitle = "pistol";
       break;
     case 3:
       weaponTitle = "shotgun";
       break;
     case 4:
       weaponTitle = "assault";
       break;
     case 5:
       weaponTitle = "sniper";
       break;
     case 6:
       weaponTitle = "flamethrower";
       break;
     case 7:
       weaponTitle = "minigun";
       break;
     case 8:
       weaponTitle = "rocket";
       break;
   }
   if (!"".equals(weaponTitle)) {
     for (AbstractWeapon weapon : person.getWeaponList()) {
       if (weapon.getName().equals(weaponTitle)) {
         person.setWeapon(weapon);
         break;
       }
     }
   }
 }