public Vector2 HexPixel(HexLoc h) { float x = (or.f0 * h.q + or.f1 * h.r) * size.x; float y = (or.f2 * h.q + or.f3 * h.r) * size.y; return(new Vector2((float)(x + origin.x), (float)(y + origin.y))); }
public override bool Equals(Object o) { if (o.GetType() != typeof(HexLoc)) { return(false); } HexLoc h = (HexLoc)o; return(this == h); }
public HexLoc Rotate(int steps) { HexLoc l = this; for (int i = 0; i < steps; i++) { l = l.Rotate60(); } return(l); }
public Vector2[] PolygonCorners(HexLoc h) { Vector2[] corners = new Vector2[6]; Vector2 center = HexPixel(h); for (int i = 0; i < 6; i++) { Vector2 offset = CornerOffset(i); corners[i] = center + offset; } return(corners); }
public static Hex GetHexAtMouse(WorldMap wm) { Vector3 worldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); HexLoc l = GameManager.l.PixelHex(worldPos); if (wm.map.ContainsKey(l)) { Hex h = wm.map[l]; return(h); } return(null); }
public int Distance(HexLoc b) { return((this - b).Length()); }