Exemplo n.º 1
0
  private boolean interact(Obstacle obstacle) {
    ArrayList<Point> ptList = new ArrayList<Point>();
    Point[] pts = obstacle.getPoints();

    for (Point p : pts) {
      double distance = p.distance(msc.x, msc.y);
      if (distance > 25 && distance < 75) {
        ptList.add(p);
      }
    }

    if (ptList.size() > 0) {
      long t = System.currentTimeMillis();
      int attempts = 0;
      while (attempts < 5 && Timing.timeFromMark(t) < 5000) {
        int r = General.random(0, ptList.size() - 1);
        Point p = ptList.get(r);
        Mouse.move(p);
        if (waitUptext(obstacle.getUptext(), 200)) {
          Mouse.click(1);
          return true;
        }
        attempts++;
      }
    }

    return false;
  }