Ejemplo n.º 1
0
  public void placeTower() {
    idealTowerSpawnLocations = null;
    turnsWaitedForTowerSpawnLocationMessage = 0;
    towerSpawnFromLocation = null;
    towerSpawnLocation = null;
    turnsWaitedForMove = 0;

    ArrayList<MapLocation> towers; // //sensing.senseAlliedTeleporters();
    int towerID = BroadcastMessage.everyone;
    MapLocation location;
    Robot robot;

    towers = sensing.senseAlliedTowerLocations();
    if (towers.size() > 0) {
      // no teles in range, but there are other towers.  they should be talking to the tele and
      // should know the status of where to build
      try {
        location = navigation.findClosest(towers);
        if (controller.canSenseSquare(location) && location != null) {
          robot = controller.senseGroundRobotAtLocation(location);
          if (robot != null) towerID = robot.getID();
          else pa("cannot sense robot at " + location);
        }
        messaging.sendTowerBuildLocationRequest(towerID);
        setGoal(Goal.askingForTowerLocation);
        return;
      } catch (Exception e) {
        pa("----Caught exception in place tower. " + e.toString());
      }
    }

    // no towers in range, lets just ask everyone
    messaging.sendTowerBuildLocationRequest(BroadcastMessage.everyone);
    setGoal(Goal.askingForTowerLocation);
    return;
  }