Ejemplo n.º 1
0
  public Trame2(byte ID, ListeCaseCommunication listCase) {

    int i = 2;
    // this.tailleTrame=tailleTrame;

    this.ID = ID;
    this.pile = listCase.getArrayList();

    this.typeTrame = 1;

    this.contenuT =
        new byte
            [(byte)
                (this.pile.size() * 3
                    + 3)]; // on récupère la taille du tab, chaque case contient 3 infos + taille
                           // trame, type et ID

    this.contenuT[0] = (byte) (this.pile.size() * 3 + 3);
    this.contenuT[1] = this.ID;

    for (Case Case1 : this.pile) {

      this.contenuT[i] = (byte) Case1.getX();
      this.contenuT[i + 1] = (byte) Case1.getY();
      this.contenuT[i + 2] = Case1.getCompo();
      i = i + 3;
    }

    this.contenuT[i] = (byte) this.typeTrame;
  }
Ejemplo n.º 2
0
 public Case toCase() {
   if (this.typeTrame == 1) {
     Case nouvelleCase =
         new Case(
             (int) this.contenuT[this.contenuT.length - 4],
             (int) this.contenuT[this.contenuT.length - 3]);
     nouvelleCase.update(this.contenuT[this.contenuT.length - 2]);
     return nouvelleCase;
   } else {
     return null;
   }
 }
Ejemplo n.º 3
0
  // trame avec position initiale du robot (x/y/orientation)
  public Trame2(byte ID, Case firstCase, int direction) {
    this.ID = ID;
    this.direction = direction;
    this.typeTrame = 2;
    this.X = firstCase.getX();
    this.Y = firstCase.getY();

    this.contenuT = new byte[6];

    this.contenuT[0] = 6;
    this.contenuT[1] = this.ID;
    this.contenuT[2] = (byte) this.X;
    this.contenuT[3] = (byte) this.Y;
    this.contenuT[4] = (byte) this.direction;
    this.contenuT[5] = (byte) this.typeTrame;
  }