Пример #1
0
  @Override
  public void update(double t) {

    { // UPDATE TOWERS
      for (Tile[] tiles : getTiles())
        for (Tile tile : tiles) if (tile.hasTower()) tile.getTower().update(t);
    }

    { // UPDATE BULLETS
      final Iterator<Bullet> it = getBullets().iterator();

      while (it.hasNext()) {

        final Bullet b = it.next();

        if (b.update(t)) it.remove();
      }
    }

    { // UPDATE MOBS
      final Iterator<Mob> it = getMobs().iterator();

      while (it.hasNext()) {

        final Mob m = it.next();

        m.update(t);

        if (m.shouldBeRemoved()) {
          m.onRemove(getGame());
          it.remove();
        }
      }
    }
  }
Пример #2
0
  public void update() {
    super.update();

    if (health <= 0) {
      die();
    }

    attackTimer++;

    if (attackTimer % 150 == 0) {
      attemptAttack();
    }
    ArrayList<Player> nearMobs = World.current.getPlayersInRadius(this, World.current.tileSize * 4);

    if (nearMobs.size() > 0) {
      if (target == null) target = nearMobs.get(0);
    }

    if (target != null) {
      moveToTarget();
    } else {
      int changeDir = random.nextInt(100);
      if (changeDir == 5) {
        direction = random.nextInt(5);
      }

      if (direction == 1) {
        move(1, 0);
      } else if (direction == 2) {
        move(-1, 0);
      } else if (direction == 3) {
        move(0, 1);
      } else if (direction == 4) {
        move(0, -1);
      }
    }
  }
Пример #3
0
 public void update(int nextHalt) {
   super.update(nextHalt);
   updateShooting();
   updateStabbing();
 }