Beispiel #1
0
  /**
   * Action to do when this agent reaches the target of current task.
   *
   * <p>This method is called when this agent goes to state <em>TARGET_REACHED</em>. If current task
   * is <tt> TASK_GIVE_MEDICPAKS</tt>, agent must give medic packs, but in other case, it calls to
   * parent's method.
   *
   * <p><em> It's very useful to overload this method. </em>
   *
   * @param _CurrentTask
   */
  protected void PerformTargetReached(CTask _CurrentTask) {

    switch (_CurrentTask.getType()) {
      case CTask.TASK_NONE:
        break;

      case CTask.TASK_GIVE_MEDICPAKS:
        int iPacks = _CurrentTask.getPacksDelivered();
        super.PerformTargetReached(_CurrentTask);
        if (iPacks != _CurrentTask.getPacksDelivered())
          System.out.println(
              getLocalName()
                  + ": Medic has left "
                  + (_CurrentTask.getPacksDelivered() - iPacks)
                  + " Medic Packs");
        else System.out.println(getLocalName() + ": Medic cannot leave Medic Packs");
        break;
      case CTask.TASK_GOTO_POSITION:
        super.PerformTargetReached(_CurrentTask);
        double x = 10 + (Math.random() * m_Map.GetSizeX());
        double z = 10 + (Math.random() * m_Map.GetSizeZ());
        int y = 0;

        String sNewPosition = " ( " + (int) x + " , " + y + " , " + (int) z + " ) ";
        AddTask(CTask.TASK_GOTO_POSITION, getAID(), sNewPosition, 1500);
        break;
      default:
        super.PerformTargetReached(_CurrentTask);
        break;
    }
  }
Beispiel #2
0
  /**
   * Action to do when this agent reaches the target of current task.
   *
   * <p>This method is called when this agent goes to state <em>TARGET_REACHED</em>. If current task
   * is <tt> TASK_GIVE_MEDICPAKS</tt>, agent must give medic packs, but in other case, it calls to
   * parent's method.
   *
   * <p><em> It's very useful to overload this method. </em>
   *
   * @param _CurrentTask
   */
  protected void PerformTargetReached(CTask _CurrentTask) {

    switch (_CurrentTask.getType()) {
      case CTask.TASK_NONE:
        break;

      case CTask.TASK_GIVE_MEDICPAKS:
        int iPacks = _CurrentTask.getPacksDelivered();
        super.PerformTargetReached(_CurrentTask);
        if (iPacks != _CurrentTask.getPacksDelivered())
          System.out.println(
              getLocalName()
                  + ": Medic has left "
                  + (_CurrentTask.getPacksDelivered() - iPacks)
                  + " Medic Packs");
        else System.out.println(getLocalName() + ": Medic cannot leave Medic Packs");
        break;

      default:
        super.PerformTargetReached(_CurrentTask);
        break;
    }
  }