Example #1
0
 public void onHitRobot(HitRobotEvent event) {
   if (event.getBearing() > -90 && event.getBearing() <= 90) {
     setBack(100);
   } else {
     setAhead(100);
   }
 }
Example #2
0
 /**
  * onHitRobot: If it's our fault, we'll stop turning and moving, so we need to turn again to keep
  * spinning.
  */
 public void onHitRobot(HitRobotEvent e) {
   if (e.getBearing() > -10 && e.getBearing() < 10) {
     fire(3);
   }
   if (e.isMyFault()) {
     turnRight(10);
   }
 }
  /** @param HitRobotEvent e, The event generated when a robot hit our robot */
  public void onHitRobot(HitRobotEvent e) {
    // if our robots health drops under
    if ((getEnergy() < LAST_STAND_HEALTH) && (!lastChance)) {
      lastChance = true;
      swapPositions();
    }

    current_mode = CLOSE_COMBAT_MODE;
    printMode();
    double gunTurnAmt =
        normalRelativeAngleDegrees(e.getBearing() + (getHeading() - getRadarHeading()));
    turnGunRight(gunTurnAmt);
    fire(3);
    guyWhoHitMe = e.getName();
    // scan();

    // if(! isPositionedCorrectly())
    // swapPositions();
    /*
     * ahead(500); turnRight(360-getHeading());
     * ahead((getBattleFieldHeight()-getY())-50);
     *
     * turnRight(90); turnGunRight(getHeading()); turnGunRight(90);
     * ahead((getBattleFieldWidth()-getX())-50);
     */
  }
 /** onHitRobot: Set him as our new target */
 @Override
 public void onHitRobot_(solomon s, HitRobotEvent e) {
   // Only print if he's not already our target.
   if (trackName != null && !trackName.equals(e.getName())) {
     // out.println("Tracking " + e.getName() + " due to collision");
   }
   // Set the target
   trackName = e.getName();
   // Back up a bit.
   // Note:  We won't get scan events while we're doing this!
   // An AdvancedRobot might use setBack(); execute();
   gunTurnAmt = normalRelativeAngle(e.getBearing() + (s.getHeading() - s.getRadarHeading()));
   s.turnGunRight(gunTurnAmt);
   s.fire(3);
   s.back(50);
 }