Пример #1
0
  @Override
  public void onStep(Controller controller, Snapshot snapshot) throws ConfusedException {
    FieldObject target = getTarget(snapshot);

    if ((snapshot == null) || (snapshot.getBalle().getPosition() == null) || (target == null))
      return;

    Orientation usToTar, midToTar, tarToGoal;
    usToTar = target.getPosition().sub(snapshot.getBalle().getPosition()).getOrientation();
    midToTar =
        snapshot.getPitch().getPosition().sub(snapshot.getBalle().getPosition()).getOrientation();
    tarToGoal =
        snapshot.getOpponentsGoal().getPosition().sub(target.getPosition()).getOrientation();

    if (midToTar.sub(midToTar).abs().degrees() > 90)
      executorStrategy.updateTarget(target, midToTar);
    else executorStrategy.updateTarget(target, usToTar);

    // Draw the target
    addDrawables(executorStrategy.getDrawables());
    if (target.getPosition() != null) addDrawable(new Dot(target.getPosition(), getTargetColor()));

    // If it says it is not finished, tell it to do something for a step.
    if (!executorStrategy.isFinished(snapshot)) {
      executorStrategy.step(controller, snapshot);

    } else {
      // Tell the strategy to stop doing whatever it was doing
      executorStrategy.stop(controller);
    }
  }
Пример #2
0
 @Override
 public void stop(Controller controller) {
   executorStrategy.stop(controller);
 }