@Test public void testUpdateEnemy() { GunDataManager gdm = newGunDataManager(); gdm.newEnemy(_shadowSre, _enemyLocation, 0, 1, true); Point2D.Double newLocation = new Point2D.Double(500, 500); GunEnemy shadowData = gdm.updateEnemy( _eventHelper.newScannedRobotEvent("Shadow", 93.0, 2, 50, 3.0, -2.0), newLocation, 0, 1, true); assertEquals(_shadowSre.getName(), shadowData.botName); assertEquals(93.0, shadowData.energy, 0.01); assertEquals(50, shadowData.distance, 0.01); assertEquals(3.0, shadowData.lastScanState.heading, 0.01); assertEquals(-2.0, shadowData.lastScanState.velocity, 0.01); assertEquals(newLocation, shadowData.lastScanState.location); }
public GunEnemy updateEnemy(ScannedRobotEvent e, Point2D.Double enemyLocation, double absBearing, int currentRound, boolean is1v1) { GunEnemy gunData = getEnemyData(e.getName()); long timeSinceLastScan = e.getTime() - gunData.lastScanState.time; gunData.timeSinceDirectionChange += timeSinceLastScan; gunData.timeSinceVelocityChange += timeSinceLastScan; gunData.updateTimers(e.getVelocity()); gunData.distance = e.getDistance(); gunData.absBearing = absBearing; gunData.energy = e.getEnergy(); gunData.lastScanRound = currentRound; gunData.previousVelocity = gunData.lastScanState.velocity; gunData.setRobotState(RobotState.newBuilder() .setLocation(enemyLocation) .setHeading(e.getHeadingRadians()) .setVelocity(e.getVelocity()) .setTime(e.getTime()) .build()); gunData.timeAliveTogether++; if (gunData.advancingVelocity() > 6) { gunData.timeMovingAtMe++; } if (is1v1) { _duelEnemy = gunData; } return gunData; }
GunDataManager extends EnemyDataManager<GunEnemy> { public GunEnemy updateEnemy(ScannedRobotEvent e, Point2D.Double enemyLocation, double absBearing, int currentRound, boolean is1v1) { GunEnemy gunData = getEnemyData(e.getName()); long timeSinceLastScan = e.getTime() - gunData.lastScanState.time; gunData.timeSinceDirectionChange += timeSinceLastScan; gunData.timeSinceVelocityChange += timeSinceLastScan; gunData.updateTimers(e.getVelocity()); gunData.distance = e.getDistance(); gunData.absBearing = absBearing; gunData.energy = e.getEnergy(); gunData.lastScanRound = currentRound; gunData.previousVelocity = gunData.lastScanState.velocity; gunData.setRobotState(RobotState.newBuilder() .setLocation(enemyLocation) .setHeading(e.getHeadingRadians()) .setVelocity(e.getVelocity()) .setTime(e.getTime()) .build()); gunData.timeAliveTogether++; if (gunData.advancingVelocity() > 6) { gunData.timeMovingAtMe++; } if (is1v1) { _duelEnemy = gunData; } return gunData; } }
GunDataManager extends EnemyDataManager<GunEnemy> { public GunEnemy updateEnemy(ScannedRobotEvent e, Point2D.Double enemyLocation, double absBearing, int currentRound, boolean is1v1) { GunEnemy gunData = getEnemyData(e.getName()); long timeSinceLastScan = e.getTime() - gunData.lastScanState.time; gunData.timeSinceDirectionChange += timeSinceLastScan; gunData.timeSinceVelocityChange += timeSinceLastScan; gunData.updateTimers(e.getVelocity()); gunData.distance = e.getDistance(); gunData.absBearing = absBearing; gunData.energy = e.getEnergy(); gunData.lastScanRound = currentRound; gunData.previousVelocity = gunData.lastScanState.velocity; gunData.setRobotState(RobotState.newBuilder() .setLocation(enemyLocation) .setHeading(e.getHeadingRadians()) .setVelocity(e.getVelocity()) .setTime(e.getTime()) .build()); gunData.timeAliveTogether++; if (gunData.advancingVelocity() > 6) { gunData.timeMovingAtMe++; } if (is1v1) { _duelEnemy = gunData; } return gunData; } GunDataManager(int enemiesTotal, BattleField battleField,
      MovementPredictor predictor, Collection<RoboGraphic> renderables,
      OutputStream out); }
GunDataManager extends EnemyDataManager<GunEnemy> { public GunEnemy updateEnemy(ScannedRobotEvent e, Point2D.Double enemyLocation, double absBearing, int currentRound, boolean is1v1) { GunEnemy gunData = getEnemyData(e.getName()); long timeSinceLastScan = e.getTime() - gunData.lastScanState.time; gunData.timeSinceDirectionChange += timeSinceLastScan; gunData.timeSinceVelocityChange += timeSinceLastScan; gunData.updateTimers(e.getVelocity()); gunData.distance = e.getDistance(); gunData.absBearing = absBearing; gunData.energy = e.getEnergy(); gunData.lastScanRound = currentRound; gunData.previousVelocity = gunData.lastScanState.velocity; gunData.setRobotState(RobotState.newBuilder() .setLocation(enemyLocation) .setHeading(e.getHeadingRadians()) .setVelocity(e.getVelocity()) .setTime(e.getTime()) .build()); gunData.timeAliveTogether++; if (gunData.advancingVelocity() > 6) { gunData.timeMovingAtMe++; } if (is1v1) { _duelEnemy = gunData; } return gunData; } GunDataManager(int enemiesTotal, BattleField battleField,
      MovementPredictor predictor, Collection<RoboGraphic> renderables,
      OutputStream out); @Override void initRound(); void execute(int currentRound, long currentTime, double bulletPower,
      double currentGunHeat, Point2D.Double myLocation, boolean is1v1,
      boolean painting); GunEnemy newEnemy(ScannedRobotEvent e, Point2D.Double enemyLocation,
      double absBearing, int currentRound, boolean is1v1); GunEnemy updateEnemy(ScannedRobotEvent e, Point2D.Double enemyLocation,
      double absBearing, int currentRound, boolean is1v1); void onBulletHit(BulletHitEvent e, long currentTime); void onBulletHitBullet(BulletHitBulletEvent e, long currentTime); double getDamageGiven(); double getAverageEnergy(); void markFiringWaves(long currentTime, boolean is1v1); void fireNextTickWave(Point2D.Double myNextLocation,
      Point2D.Double targetLocation, String targetName, int currentRound,
      long currentTime, double bulletPower, double myEnergy, double gunHeat,
      double myHeading, double myVelocity, int enemiesAlive); void addListener(GunDataListener listener); int getEnemiesTotal(); int getDuelDataSize(); void drawVictory(long startTime); }
GunDataManager extends EnemyDataManager<GunEnemy> { public GunEnemy updateEnemy(ScannedRobotEvent e, Point2D.Double enemyLocation, double absBearing, int currentRound, boolean is1v1) { GunEnemy gunData = getEnemyData(e.getName()); long timeSinceLastScan = e.getTime() - gunData.lastScanState.time; gunData.timeSinceDirectionChange += timeSinceLastScan; gunData.timeSinceVelocityChange += timeSinceLastScan; gunData.updateTimers(e.getVelocity()); gunData.distance = e.getDistance(); gunData.absBearing = absBearing; gunData.energy = e.getEnergy(); gunData.lastScanRound = currentRound; gunData.previousVelocity = gunData.lastScanState.velocity; gunData.setRobotState(RobotState.newBuilder() .setLocation(enemyLocation) .setHeading(e.getHeadingRadians()) .setVelocity(e.getVelocity()) .setTime(e.getTime()) .build()); gunData.timeAliveTogether++; if (gunData.advancingVelocity() > 6) { gunData.timeMovingAtMe++; } if (is1v1) { _duelEnemy = gunData; } return gunData; } GunDataManager(int enemiesTotal, BattleField battleField,
      MovementPredictor predictor, Collection<RoboGraphic> renderables,
      OutputStream out); @Override void initRound(); void execute(int currentRound, long currentTime, double bulletPower,
      double currentGunHeat, Point2D.Double myLocation, boolean is1v1,
      boolean painting); GunEnemy newEnemy(ScannedRobotEvent e, Point2D.Double enemyLocation,
      double absBearing, int currentRound, boolean is1v1); GunEnemy updateEnemy(ScannedRobotEvent e, Point2D.Double enemyLocation,
      double absBearing, int currentRound, boolean is1v1); void onBulletHit(BulletHitEvent e, long currentTime); void onBulletHitBullet(BulletHitBulletEvent e, long currentTime); double getDamageGiven(); double getAverageEnergy(); void markFiringWaves(long currentTime, boolean is1v1); void fireNextTickWave(Point2D.Double myNextLocation,
      Point2D.Double targetLocation, String targetName, int currentRound,
      long currentTime, double bulletPower, double myEnergy, double gunHeat,
      double myHeading, double myVelocity, int enemiesAlive); void addListener(GunDataListener listener); int getEnemiesTotal(); int getDuelDataSize(); void drawVictory(long startTime);  }