예제 #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)));
 }