Пример #1
0
 private void establishEdges()
 {
     // Loop through all of the GridPoints
     for (int i = 0; i < grid.GetLength(0); i++)
     {
         // Loop through all cells belonging to the GridPoint
         foreach (GameObject cell in grid[i].cells)
         {
             //This will loop through all of the cells neighbors and check if the neighbor is within the same Island
             //i.e., they share the same closestPoint
             GameTile cellGT = cell.GetComponent <GameTile>();
             foreach (KeyValuePair <string, GameTile> gt in cellGT.GetNeighbors())
             {
                 //If they are not in the same island, then it must be a neighbor
                 if (!gt.Value.closestGridPoint.Equals(cellGT.closestGridPoint) && !grid[i].neighbors.Contains(gt.Value.closestGridPoint))
                 {
                     grid [i].neighbors.Add(gt.Value.closestGridPoint);
                     //Debug.Log ("Not within the same island");
                 }
             }
         }
     }
 }