示例#1
0
文件: Map.cs 项目: jadmz/HexMap
 /// <summary>
 /// Gets the distance between two tiles.
 /// </summary>
 /// <param name='tile1'>
 /// Tile1.
 /// </param>
 /// <param name='tile2'>
 /// Tile2.
 /// </param>
 public float distance(HexTile tile1, HexTile tile2)
 {
     if(tile1 == null || tile2 == null){
         return 0;
     }
     Vector3 pos1 = tile1.getCoordinates();
     Vector3 pos2 = tile2.getCoordinates();
     float dist = Mathf.Abs(pos1.x - pos2.x);
     dist = Mathf.Max(Mathf.Abs(pos1.y-pos2.y), dist);
     dist = Mathf.Max(Mathf.Abs(pos1.z-pos2.z), dist);
     return dist;
 }