Пример #1
0
  public void using(Gun gun) {
    if (guns == null) {
      guns = new HashMap<GunType, Gun>();
    }

    if (guns.get(gun.type()) != null) {
      guns.get(gun.type()).updateFrequency();
    } else {
      gun.updateFrequency();
      guns.put(gun.type(), gun);
    }
  }
Пример #2
0
  public void paintAllGuns(Graphics g) {

    for (Gun gun : gunList) {
      gun.goUp();
    }
    if (!gunList.isEmpty()) {
      for (Gun gun : gunList) {
        // System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!ATACK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
        gun.paintGun(g);
      }
    }
  }
Пример #3
0
 public void drawGun(Gun gun, Graphics g) {
   g.drawImage(
       gun.getImage(),
       gun.getX(),
       gun.getY(),
       gun.getX() + 100,
       gun.getY() + 50,
       0,
       0,
       100,
       100,
       null);
 }
Пример #4
0
 public void updateGuns() {
   try {
     int i = 0;
     // System.out.println("Nro guns: ..............."+gunList.size());
     for (Gun gun : gunList) {
       if (gun.getYM() <= 0) {
         gunList.remove(gun);
       }
       // System.out.println("Gun nro: "+i+";......................ym= "+gun.getYM()+"; xm=
       // "+gun.getXM());
       i++;
     }
   } catch (Exception e) {
     System.out.println("error in the updateGuns!!!!");
   }
 }
  public void maybe_fire_guns() {
    Enumeration gs;
    Gun gun;
    TwoWheeledVehicle v;

    gs = this.guns.elements();
    while (gs.hasMoreElements()) {
      gun = (Gun) gs.nextElement();
      if (gun.firing()) {
        gun.fired_flag = true;
        v = gun.vehicle_hit_by(world);
        if (!(v == null)) {
          gun.apply_to_vehicle(v);
        }
      }
    }
  }