public void clean() throws Exception { af.countNonEmptyCells(); moveToQuadrant(1, 1); turn(Direction.RIGHT); while (af.checkFieldEmpty() == false) { fire(); if (af.checkBulletOutOfField() == true) { move(Direction.DOWN); turn(Direction.RIGHT); } } }
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() throws Exception { Bullet bullet = new Bullet((x + 25), (y + 25), direction); af.processFire(bullet); }
public void moveRandomWithFire() { af.processMoveRandomWithFire(this); }
public void fire() { Bullet bullet = new Bullet((x + 27), (y + 27), direction, tower); af.processFire(bullet, this); }
public void move() { af.processMove(this); }
public void moveRandom() { af.processMoveRandom(this); }
public static void main(String[] args) throws Exception { ActionField af = new ActionField(); af.runTheGame(); }
public void turn(int direction) { this.direction = direction; af.processTurn(this); }
public void fire() throws Exception { Bullet bullet = new Bullet(x + 25, y + 25, direction); actionField.processFire(bullet); }
public void move() throws Exception { actionField.processMove(this); }
public void moveToQuadrant(int v, int h) throws Exception { actionField.processMoveToQuadrant(v, h); }
public void move() throws Exception { af.processMove(this); }
void fire() throws Exception { Bullet bullet = new Bullet(x + 25, y + 25, direction); af.processFire(bullet); }
public void move(Direction direction) throws Exception { this.direction = direction; af.processMove(this); }
public void turn(Direction direction) throws Exception { this.direction = direction; af.processTurn(this); }