public ArrayList<Integer> getEachTankDamage() { ArrayList<Integer> damages = new ArrayList<Integer>(); for (Tank t : tanks) { damages.add(t.fire(getFortress())); } notifyListeners(); return damages; }
public int fireLeft() throws Exception { String str = getQuadrantXY(tank.getX(), tank.getY()); int tankV = Integer.valueOf(str.substring(0, 1)); int tankH = Integer.valueOf(str.substring(2, str.length())); tank.turn(Direction.LEFT); for (int idx = tankV; idx < tankV + 1; idx++) { for (int j = tankH; j >= 0; j--) { if (battleField.scanQuadrant(idx, j) == "B") { tank.fire(); } } } return tankH; }
public int fireDown() throws Exception { String str = getQuadrantXY(tank.getX(), tank.getY()); int tankV = Integer.valueOf(str.substring(0, 1)); int tankH = Integer.valueOf(str.substring(2, str.length())); tank.turn(Direction.DOWN); for (int idx = tankV; idx < battleField.getBattleField().length; idx++) { for (int j = tankH; j < tankH + 1; j++) { if (battleField.scanQuadrant(idx, j) == "B") { tank.fire(); } } } return tankV; }
public void keyReleased(KeyEvent e) { int key = e.getKeyCode(); switch (key) { case KeyEvent.VK_CONTROL: fire(); break; case KeyEvent.VK_LEFT: bL = false; break; case KeyEvent.VK_UP: bU = false; break; case KeyEvent.VK_RIGHT: bR = false; break; case KeyEvent.VK_DOWN: bD = false; break; } locateDirection(); }