示例#1
0
  public boolean hitTank(Tank t) {
    if (this.isLive()
        && t.isLive()
        && (this.isGood() != t.isGood())
        && this.getRect().intersects(t.getRect())) {
      // Missile
      this.setLive(false);
      tc.missileList.remove(this);

      // Tank
      if (t.isGood()) {
        t.setLife(t.getLife() - Tank.LIFE_MAX / 5);
        if (t.getLife() == 0) {
          t.setLive(false);
        }
      } else {
        t.setLive(false);
      }

      // Explode
      Explode e = new Explode(t.x, t.y, this.tc);
      tc.explodeList.add(e);

      return true;
    }

    return false;
  }
示例#2
0
  public boolean hitTanks(List<Tank> ts) {

    Tank t = null;
    for (int i = 0; i < ts.size(); i++) {
      t = ts.get(i);
      if (t.isLive() && t != null) {
        if (hitTank(t)) {
          return true;
        }
      }
    }
    return false;
  }