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); } }
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); }
public T TileCompFromCoords(HexCoordinates coords) { return(_tileComps[coords]); }
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)); }
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); }
public List <HexTile> TilesInRange(HexCoordinates index, int range) { return(TilesInRange(TileAt(index), range)); }
public List <HexTile> Neighbours(HexCoordinates index) { return(Neighbours(TileAt(index))); }