public void moveToQuadrant(int v, int h) { String coordinates = af.getQuadrantXY(v, h); int y = Integer.parseInt(coordinates.substring(0, coordinates.indexOf("_"))); int x = Integer.parseInt(coordinates.substring(coordinates.indexOf("_") + 1)); if (getX() < x) { while (getX() != x) { turn(Direction.RIGHT); move(); } } else { while (getX() != x) { turn(Direction.LEFT); move(); } } if (getY() < y) { while (getY() != y) { turn(Direction.DOWN); move(); } } else { while (getY() != y) { turn(Direction.UP); move(); } } }
public void turn(Direction direction) { this.direction = direction; try { af.repaint(); } catch (Exception e) { System.out.println("Repaint exception"); } }
boolean checkRight(int checkX, int checkY) { for (; checkX < 9; checkX++) { if (bf.scanQuadrant2(checkY, checkX) instanceof Rock || af.getQuadrantString(checkX, checkY).equals(enemyTankPosition())) { return true; } } return false; }
public int battleFieldScanner() { for (int fieldX = 0; fieldX < bf.getDimentionX(); fieldX++) { for (int fieldY = 0; fieldY < bf.getDimentionY(); fieldY++) if ((af.getQuadrantString(fieldX, fieldY).equals(enemyTankPosition())) || (bf.scanQuadrant2(fieldY, fieldX) instanceof Rock)) { return fieldX + 1; } } return 0; }
public void reappear() { try { Thread.sleep(1000); } catch (Exception e) { System.out.println("Exception"); } x = new Random().nextInt(bf.getDimentionX()) * 64; y = new Random().nextInt(bf.getDimentionY()) * 64; af.repaint(); }
boolean lineScanner(Direction direction) { String checkQuad = af.getQuadrant(this.x, this.y); int checkX = Integer.parseInt(checkQuad.substring(0, checkQuad.indexOf("_"))); int checkY = Integer.parseInt(checkQuad.substring(checkQuad.indexOf("_") + 1)); if (checkX >= 0 && checkX < 9 && checkY >= 0 && checkY < 9) { if (checkDirection(direction, checkX, checkY)) { return true; } } return false; }
public void destroy() { if (this instanceof Tiger) { Tiger t = (Tiger) this; if (t.getArmor() > 0) { t.setArmor(0); return; } else { t.setArmor(1); } } x = -100; y = -100; af.repaint(); reappear(); }
public void fire() { Bullet bullet = new Bullet((x + 27), (y + 27), direction, tower); af.processFire(bullet, this); }
public void moveRandomWithFire() { af.processMoveRandomWithFire(this); }
public void moveRandom() { af.processMoveRandom(this); }
public void move() { af.processMove(this); }