Esempio n. 1
0
  protected void setup() {
    AddServiceType("Mensajero");

    super.setup();
    SetUpPriorities();

    // cojo la posición de la bandera
    posBandera.x = m_Map.GetTargetX();
    posBandera.y = m_Map.GetTargetY();
    posBandera.z = m_Map.GetTargetZ();

    m_AidListaMensajeros = new Vector<AID>();
    buscarMensajeros();

    addBehaviour(
        new CyclicBehaviour() { // Ver mensajes recibidos
          public void action() {
            MessageTemplate template =
                MessageTemplate.and(
                    MessageTemplate.MatchPerformative(ACLMessage.INFORM),
                    MessageTemplate.MatchConversationId("MS"));
            ACLMessage msg = receive(template);
            if (msg != null) {
              AID owner = msg.getSender();
              mensajeRecibido(msg);
            }
          }
        });
  }
Esempio n. 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;
    }
  }
Esempio n. 3
0
  /**
   * Calculates an array of positions for patrolling.
   *
   * <p>When this method is called, it creates an array of <tt> n</tt> random positions. For medics
   * and fieldops, the rank of <tt> n</tt> is [1..1]. For soldiers, the rank of <tt> n</tt> is
   * [5..10].
   *
   * <p><em> It's very useful to overload this method. </em>
   */
  protected void CreateControlPoints() {

    int iMaxCP = 0;

    switch (m_eClass) {
      case CLASS_MEDIC:
      case CLASS_FIELDOPS:
        super.CreateControlPoints();
        break;

      case CLASS_SOLDIER:

        // aqui tengo que cambiar posBandera por posBaseAllied
        // m_Map.getClass().getField(m_sMedicService)
        // CTerrainMap.this.getClass().getField(name)

        // m_AlliedBase no la reconoce la variable
        int xini = (int) (posBandera.x) / 8;
        int zini = (int) (posBandera.z) / 8;
        int x = xini;
        int z = zini;
        while (z < 32 && x > 0 && (Math.abs(x - xini) <= 3) && m_Map.CanWalk(x - 1, z + 1)) {
          x--;
          z++;
        }
        double x2 = x * 8;
        double z2 = z * 8;

        m_ControlPoints = new Vector3D[4];
        m_ControlPoints[0] = new Vector3D(x2, 0, z2 + 7);
        m_ControlPoints[1] = new Vector3D(x2 - 7, 0, z2);
        m_ControlPoints[2] = new Vector3D(x2, 0, z2 - 7);
        m_ControlPoints[3] = new Vector3D(x2 + 7, 0, z2);

        m_iControlPointsIndex = 0;
        break;

      case CLASS_ENGINEER:
      case CLASS_NONE:
      default:
        break;
    }
  }
Esempio n. 4
0
  /**
   * Request for backup.
   *
   * <p>This method sends a <b> FIPA REQUEST </b> message to all agents who offers the <tt>
   * m_sBackupService</tt> service.
   *
   * <p>The content of message is: <tt> ( x , y , z ) ( SoldiersCount ) </tt>.
   *
   * <p>Variable <tt> m_iSoldiersCount </tt> is updated.
   *
   * <p><em> It's very useful to overload this method. </em>
   */
  protected void CallForBackup() {

    super.CallForBackup();
  }
Esempio n. 5
0
  /**
   * Request for ammunition.
   *
   * <p>This method sends a <b> FIPA REQUEST </b> message to all agents who offers the <tt>
   * m_sAmmoService </tt> service.
   *
   * <p>The content of message is: <tt> ( x , y , z ) ( ammo ) </tt>.
   *
   * <p>Variable <tt> m_iFieldOpsCount </tt> is updated.
   *
   * <p><em> It's very useful to overload this method. </em>
   */
  protected void CallForAmmo() {

    super.CallForAmmo();
  }