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); } }
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(); }
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); } } }
public void spawnTeleporter() { // there were no towers in range ever, so lets just build a new one: towerSpawnLocation = spawning.getTowerSpawnLocation(); if (towerSpawnLocation == null) { pa("WTF. There is nowhere to spawn the tower."); return; } towerSpawnFromLocation = towerSpawnLocation.subtract(controller.getLocation().directionTo(towerSpawnLocation)); navigation.changeToLocationGoal(towerSpawnFromLocation, true); controller.setIndicatorString(2, towerSpawnFromLocation.toString()); setGoal(Goal.placingTeleporter); }