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; }
public boolean hitTank(Tank t) { boolean bHitted = false; if (this.getRec().intersects(t.getRec()) && this.bGood != t.isGood()) { Explode e = new Explode(x, y); tc.explodes.add(e); if (t.isGood()) { int i = t.getLives(); i--; t.setLives(i); if (i <= 0) { t.setLive(false); } } else { t.setLive(false); } bHitted = true; this.bLive = false; } return bHitted; }