Exemplo n.º 1
2
 public ArrayList<Integer> getEachTankDamage() {
   ArrayList<Integer> damages = new ArrayList<Integer>();
   for (Tank t : tanks) {
     damages.add(t.fire(getFortress()));
   }
   notifyListeners();
   return damages;
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
 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();
 }