@Override public void actionPerformed(ActionEvent e) { /// TODO Auto-generated method stub if (e.getSource() == timer) { if (influTank.army == 1) { for (Tank otherTank : map.layer_3_CT) { if (otherTank.tankState == 5) otherTank.tankState = otherTank.tempState; } } else { for (Tank otherTank : map.layer_3_UT) { if (otherTank.tankState == 5) otherTank.tankState = otherTank.tempState; } } timer.stop(); timer = null; } else { state++; } }
public void work(Tank tank) { if (tank.army == 1) { for (Tank otherTank : map.layer_3_CT) { if (otherTank.tankState != 5) { otherTank.tempState = otherTank.tankState; otherTank.tankState = 5; } } timer = new Timer(12000, this); timer.start(); } else { for (Tank otherTank : map.layer_3_UT) { if (otherTank.tankState != 5) { otherTank.tempState = otherTank.tankState; otherTank.tankState = 5; } } timer = new Timer(5000, this); timer.start(); } influTank = tank; life--; }