示例#1
0
 void CalculateCorners(HexCoordinates coordinates,
                       HexOrientation orientation, float outerRadius)
 {
     for (int i = 0; i < CornerCount; i++)
     {
         float angle = 60 * i;
         if (orientation == HexOrientation.POINTY)
         {
             angle += 30;
         }
         angle       *= Mathf.PI / 180;
         Corners[i].x = Center.x + outerRadius * Mathf.Cos(angle);
         Corners[i].y = Center.y;
         Corners[i].z = Center.z + outerRadius * Mathf.Sin(angle);
     }
 }
示例#2
0
        public List <HexTile> TilesInRange(HexTile center, int range)
        {
            List <HexTile> ret = new List <HexTile>();
            HexCoordinates o;

            for (int dx = -range; dx <= range; dx++)
            {
                for (int dy = Mathf.Max(-range, -range - dx);
                     dy <= Mathf.Min(range, range - dx);
                     dy++)
                {
                    o = new HexCoordinates(dx, dy, -dx - dy) + center.Coords;
                    if (_tiles.ContainsKey(o))
                    {
                        ret.Add(_tiles[o]);
                    }
                }
            }
            return(ret);
        }
示例#3
0
 public T TileCompFromCoords(HexCoordinates coords)
 {
     return(_tileComps[coords]);
 }
示例#4
0
 public static int Distance(HexCoordinates a, HexCoordinates b)
 {
     return((Mathf.Abs(a._x - b._x) + Mathf.Abs(a.Z - b.Z) + Mathf.Abs(a._y - b._y)) / 2);
     // 或者 return Mathf.Max(Mathf.Abs(a.x - b.x), Mathf.Abs(a.Y - b.Y), Mathf.Abs(a.z - b.z));
 }
示例#5
0
 public int Distance(HexCoordinates a, HexCoordinates b)
 {
     return((Mathf.Abs(a.X - b.X) + Mathf.Abs(a.Y - b.Y) +
             Mathf.Abs(a.Z - b.Z)) / 2);
 }
示例#6
0
 public List <HexTile> TilesInRange(HexCoordinates index, int range)
 {
     return(TilesInRange(TileAt(index), range));
 }
示例#7
0
 public List <HexTile> Neighbours(HexCoordinates index)
 {
     return(Neighbours(TileAt(index)));
 }