public Hex GetHexByPoint(Point hexCenterPoint) { var x = Convert.ToInt32(hexCenterPoint.X / (X_CENTRE_DISTANCE_FACTOR * a)); var y = Convert.ToInt32(hexCenterPoint.Y / r); var inx = new Index2D(x, y); if (hexMap.ContainsKey(inx)) return hexMap[inx]; else return new Hex(inx); }
public Hex(Index2D inx, Point center, HexType type, int height) { r = GlobalConst.DEFAULT_r; a = 2d / Math.Sqrt(3) * r; index = inx; this.type = type; this.height = height; if (type != HexType.Empty) render = new HexRender(DisplayType.GAME_SimpleGround, height, center); }
public Hex(Index2D inx) : this(inx, new Point(), HexType.Empty, DEFAULT_HEIGHT) { }
public Point GetCoordinateByIndex(Index2D inx) { return new Point((X_CENTRE_DISTANCE_FACTOR * a) * inx.X, r * inx.Y); }