示例#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;
  }
示例#2
0
 /**
  * Waits a certain amount of time until we have no more willow logs
  *
  * @param startAmount starting amount
  * @param ms time to wait
  * @return true if current amount lower than start amount
  */
 private boolean waitSellWillows(int startAmount, int ms) {
   long t = System.currentTimeMillis();
   while (Timing.timeFromMark(t) < ms) {
     if (Inventory.find(willowID).length < startAmount) {
       return true;
     }
     General.sleep(ms / 20, ms / 10);
   }
   return false;
 }
示例#3
0
 /**
  * Waits a certain amount of time for the store screen to open
  *
  * @param ms amount of time to wait in ms
  * @return True if store opened within time limit
  */
 private boolean waitStoreOpen(int ms) {
   long t = System.currentTimeMillis();
   while (Timing.timeFromMark(t) < ms) {
     if (isStoreOpen()) {
       return true;
     } else if (Player.isMoving()) {
       t = System.currentTimeMillis();
     }
     General.sleep(ms / 20, ms / 10);
   }
   return false;
 }
示例#4
0
  private boolean waitUptext(String text, long time) {
    long t = System.currentTimeMillis();
    while (Timing.timeFromMark(t) < time) {
      String uptext = Game.getUptext();
      if (uptext != null) {
        if (uptext.contains(text)) {
          println("Found uptext: " + text);
          return true;
        }
      }
      sleep(10, 20);
    }

    return false;
  }
示例#5
0
 /**
  * Waits a certain amount of time for the right selling option to appear and click
  *
  * @param amount inventory willow amount
  * @param ms time to wait
  * @return true if clicked the right sell option
  */
 private boolean waitSellOption(int amount, int ms) {
   long t = System.currentTimeMillis();
   while (Timing.timeFromMark(t) < ms) {
     String[] options = ChooseOption.getOptions();
     for (String option : options) {
       if (option.contains("Sell willow")) {
         int number = amount >= 10 ? 10 : 5;
         if (ChooseOption.select("Sell " + number + " willow")) {
           return true;
         }
       }
     }
     General.sleep(ms / 20, ms / 10);
   }
   return false;
 }