Exemplo n.º 1
0
 // Renvoie l'autre salle portant le même numéro
 public GameObject getSisterTile()
 {
     //Debug.Log("Tile Behavior, getSisterTile: Search for sister of " + getTileName() + " of pairing " + tilePairing);
     foreach (var tileObject in GameObject.FindGameObjectsWithTag("Tile"))
     {
         TileBehavior tile = tileObject.GetComponent <TileBehavior>();
         if (tile.getTileName() != getTileName() && tile.tilePairing == tilePairing)
         {
             return(tileObject);
         }
     }
     Debug.LogWarning("Tile Behavior, assignSisterTile: Tile associée non trouvée");
     return(null);
 }
Exemplo n.º 2
0
 private void saveTiles()
 {
     GameObject[] tiles = GameObject.FindGameObjectsWithTag("Tile");
     foreach (GameObject tile in tiles)
     {
         TileBehavior      t          = tile.GetComponent <TileBehavior>();
         List <GameObject> herses     = new List <GameObject>();
         List <HerseData>  hersesData = new List <HerseData>();
         for (int i = 0; i < tile.transform.childCount; i++)
         {
             if (tile.transform.GetChild(i).GetComponent <HerseBehavior>() != null)
             {
                 herses.Add(tile.transform.GetChild(i).gameObject);
             }
         }
         foreach (GameObject herse in herses)
         {
             HerseData hData = new HerseData("", "", herse.GetComponent <HerseBehavior>().herseBrisee, herse.GetComponent <HerseBehavior>().herseOuverte);
             for (int i = 0; i < tile.transform.childCount; i++)
             {
                 if (tile.transform.GetChild(i).GetComponent <CaseBehavior>() != null)
                 {
                     if (tile.transform.GetChild(i).GetComponent <CaseBehavior>().herse == herse)
                     {
                         if (hData.cellOneName == "")
                         {
                             hData.cellOneName = tile.transform.GetChild(i).name;
                         }
                         else if (hData.cellTwoName == "")
                         {
                             hData.cellTwoName = tile.transform.GetChild(i).name;
                         }
                     }
                 }
             }
             hersesData.Add(hData);
         }
         tilesData.Add(new GameDataTile(t.getTileName(), t.index, t.hidden, t.tileRotation, hersesData));
     }
 }