Beispiel #1
0
 public void towerPingLocationCallback(MapLocation location, int robotID) {
   sensing.senseAlliedTowerLocations();
   if (!sensing.knownAlliedTowerLocations.containsKey(robotID)) {
     sensing.knownAlliedTowerLocations.put(new Integer(robotID), location);
     sensing.knownAlliedTowerIDs.put(location.getX() + "," + location.getY(), robotID);
   }
 }
Beispiel #2
0
  public void checkKnownTowerLocations() {
    Robot robot = null;

    ArrayList<MapLocation> towers = sensing.senseKnownAlliedTowerLocations();
    if (towers.size() > 0) {
      // we remember that there used to be a tower here, so lets try going there.  once we get
      // there, we can ask again
      MapLocation closest = navigation.findClosest(towers);
      if (controller.canSenseSquare(closest) && closest != null) {
        try {
          robot = controller.senseGroundRobotAtLocation(closest);
        } catch (Exception e) {;
        }
        if (robot == null) {
          int id = sensing.knownAlliedTowerIDs.remove(closest.getX() + "," + closest.getY());
          sensing.knownAlliedTowerLocations.remove(id);
        }
      }
      navigation.changeToLocationGoal(closest, true);
      setGoal(Goal.movingToPreviousTowerLocation);

      return;
    }

    spawnTeleporter();
  }
Beispiel #3
0
  public void newUnit(int senderID, MapLocation location, String robotType) {
    if (RobotType.valueOf(robotType).isBuilding()) {
      if (sensing.knownAlliedTowerLocations == null) sensing.senseAlliedTowerLocations();

      if (!sensing.knownAlliedTowerLocations.containsKey(senderID)) {
        sensing.knownAlliedTowerLocations.put(new Integer(senderID), location);
        sensing.knownAlliedTowerIDs.put(location.getX() + "," + location.getY(), senderID);
      }
    }
  }