-
Notifications
You must be signed in to change notification settings - Fork 31
/
LocationRunner.java
66 lines (45 loc) · 2.28 KB
/
LocationRunner.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import java.io.*;
import com.google.common.geometry.*;
import java.lang.*;
public class LocationRunner{
private BufferedReader br;
private ClientWrapper cw;
private S2LatLng currentLocation;
public LocationRunner(FileReader fileReader, ClientWrapper clientWrapper) throws Exception {
this.br = new BufferedReader(fileReader);
this.cw = clientWrapper;
}
public void run() throws Exception{
String curLine = br.readLine();
String[] firstLocation = curLine.split(",");
currentLocation = S2LatLng.fromDegrees(Double.parseDouble(firstLocation[0]),Double.parseDouble(firstLocation[1]));
cw.newLocation(currentLocation);
cw.printLocalHackablePortalNames();
//cw.hackLocalPortals();
GUI gui = new GUI(cw.player, cw);
while( (curLine = br.readLine()) != null ){
System.out.println("Moving to location: " + curLine);
DebugHandler.debugInfo("Moving to location: " + curLine);
System.out.println(curLine.toString());
//DebugHandler.debugInfo(curLine.toString());
String[] newLocation = curLine.split(",");
S2LatLng newLoc = S2LatLng.fromDegrees(Double.parseDouble(newLocation[0]),Double.parseDouble(newLocation[1]));
//get distance in meters
Double dist = S2Wrapper.GreatEarthDistance(currentLocation, newLoc);
TransitHandler th = new TransitHandler(currentLocation, newLoc, gui);
th.start();
int waitTimeSeconds = (int) (dist/5.0);
System.out.println("Waiting " + waitTimeSeconds + " seconds to arrive.");
DebugHandler.debugInfo("Waiting " + waitTimeSeconds + " seconds to arrive.");
th.join();
//Thread.sleep(1000 * waitTimeSeconds);
System.out.println("Arrived!");
DebugHandler.debugInfo("Arrived!");
currentLocation = newLoc;
cw.newLocation(newLoc);
cw.printLocalHackablePortalNames();
cw.hackLocalPortals();
cw.getInventory();
}
}
}