예제 #1
0
 public void enemyPosition(ScannedRobotEvent e, double x, double y) {
   // poll subtargetters for their opinions
   virtualBulletTick++;
   lastEnemyScanTime = owner.getTime();
   // only log it when we actually fire: the enemy may respond to that
   if (owner.shouldFireShot(e)) {
     double bulletPower = e.getDistance() > 500.0 ? 2.0 : 3.0;
     for (int i = 0; i < numVirtualGuns; i++) {
       double angle = targetters[i].target(e, bulletPower);
       VirtualBullet bullet = new VirtualBullet();
       bullet.targetter = i;
       bullet.x = owner.getX();
       bullet.y = owner.getY();
       bullet.velX = Targetting.bulletSpeed(bulletPower) * Math.sin(angle);
       bullet.velY = Targetting.bulletSpeed(bulletPower) * Math.cos(angle);
       bullet.lastUpdateTime = lastEnemyScanTime;
       virtualBullets.add(bullet);
     }
   }
   for (int i = 0; i < numVirtualGuns; i++) {
     targetters[i].enemyPosition(e, x, y);
   }
   enemyX = x;
   enemyY = y;
 }
예제 #2
0
    public void onScannedRobot(ScannedRobotEvent event) {
      scannedDistance = (int) (event.getDistance() + 0.5);
      scannedEnergy = Math.max(1, (int) (event.getEnergy() + 0.5));
      scannedAngle =
          (int)
              (Math.toDegrees(
                      Utils.normalAbsoluteAngle(peer.getBodyHeading() + event.getBearingRadians()))
                  + 0.5);
      scannedBearing = (int) (event.getBearing() + 0.5);
      scannedHeading = (int) (event.getHeading() + 0.5);
      scannedVelocity = (int) (event.getVelocity() + 0.5);

      JuniorRobot.this.onScannedRobot();
    }