Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2013
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1. package Walker;
  2.  
  3. import org.osbot.script.Script;
  4.  
  5. public class Path {
  6.  
  7.     private PathTile[] tiles;
  8.     private Script s;
  9.  
  10.     public int index;
  11.     public int maxIndex;
  12.     private boolean walking;
  13.     private int random;
  14.  
  15.     public Path(Script scr, PathTile[] t, int r) {
  16.     this.s = scr;
  17.     this.tiles = t;
  18.  
  19.     this.index = 0;
  20.     this.maxIndex = (t.length - 1);
  21.     this.walking = false;
  22.     this.random = r;
  23.     }
  24.  
  25.     public void start() {
  26.     this.walking = true;
  27.     }
  28.  
  29.     public void reset() {
  30.     this.index = 0;
  31.     this.walking = false;
  32.     }
  33.  
  34.     public void stop() throws InterruptedException {
  35.     this.reset();
  36.     this.s.setRunning(false);
  37.     }
  38.  
  39.     public boolean shouldStop() {
  40.     if (this.index > this.maxIndex) {
  41.         return true;
  42.     }
  43.     return false;
  44.     }
  45.  
  46.     public boolean isWalking() {
  47.     return this.walking;
  48.     }
  49.  
  50.     public PathTile next() {
  51.     PathTile rtn = this.tiles[this.index].randomize(this.s, this.random);
  52.     this.index += 1;
  53.     return rtn;
  54.     }
  55.  
  56.     public boolean shouldNext() {
  57.     PathTile x = this.testNext();
  58.     if (x != null && this.s.canReach(x) && x.random) {
  59.         return true;
  60.     }
  61.     return false;
  62.     }
  63.  
  64.     private PathTile testNext() {
  65.     if (!this.shouldStop()) {
  66.         return this.tiles[this.index].randomize(this.s, this.random);
  67.     } else {
  68.         return null;
  69.     }
  70.     }
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement