public class Tool extends GameObject { protected long time; protected long currTime; protected int tankId; public Tool(TankManager tankManager, int x_Koordinate, int y_Koordinate, int toolType) { init(tankManager, x_Koordinate, y_Koordinate, toolType); } protected void init(TankManager tankManager, int x_Koordinate, int y_Koordinate, int toolType) { this.id = this.hashCode(); time = System.currentTimeMillis(); currTime = time; } public void malen() { long elapsedTime = System.currentTimeMillis() - currTime; currTime += elapsedTime; if (tankManager.status == GameManager.PAUSE || tankManager.status == GameManager.EXIT) { time += elapsedTime; } if (System.currentTimeMillis() - time > 15000) { tankManager.toolMenge.removeElement(this); } treffenErkennen(); toolMalen(); } protected void toolMalen(){ super.malen(); } protected void treffenErkennen() { if (tankManager.tank1 != null && this.stossenGegen(tankManager.tank1)) { tankManager.tank1.toolBehandeln(objectType); tankId=tankManager.tank1.id; remove(); } if (tankManager.tank2 != null && this.stossenGegen(tankManager.tank2)) { tankManager.tank2.toolBehandeln(objectType); tankId=tankManager.tank2.id; remove(); } } protected void remove(){ tankManager.toolMenge.removeElement(this); } }