public HexPoint CreatePoint(EPointPositionOnHex position, HexLocation location) { int w = location.W; int h = location.H; HexPoint result = new HexPoint(); switch (position) { case EPointPositionOnHex.TopMiddle: result.Hex1 = new HexLocation(w - 1, h - 1); result.Hex2 = new HexLocation(w, h - 1); result.Hex3 = new HexLocation(w, h); break; case EPointPositionOnHex.RightTop: result.Hex1 = new HexLocation(w, h - 1); result.Hex2 = new HexLocation(w, h); result.Hex3 = new HexLocation(w + 1, h); break; case EPointPositionOnHex.RightBottom: result.Hex1 = new HexLocation(w, h); result.Hex2 = new HexLocation(w + 1, h); result.Hex3 = new HexLocation(w, h + 1); break; case EPointPositionOnHex.BottomMiddle: result.Hex1 = new HexLocation(w, h); result.Hex2 = new HexLocation(w - 1, h + 1); result.Hex3 = new HexLocation(w, h + 1); break; } return result; }
private Point2D AddOffset(Point2D point, EPointPositionOnHex positionOnHex) { switch (positionOnHex) { case (EPointPositionOnHex.TopMiddle): return new Point2D( point.X + Hex.HalfWidth, point.Y); case (EPointPositionOnHex.RightTop): return new Point2D( point.X + Hex.Width, point.Y + Hex.BottomHeight); case (EPointPositionOnHex.RightBottom): return new Point2D( point.X + Hex.Width, point.Y + Hex.PartialHeight); case (EPointPositionOnHex.BottomMiddle): return new Point2D( point.X + Hex.HalfWidth, point.Y + Hex.PartialHeight); } throw new ArgumentException("Enum cannot be " + positionOnHex.ToString()); }
public Point2D AddOffset(EPointPositionOnHex position, BoardVisual b, Point2D point) { Point2D result = new Point2D(); // Offsets for positioning the visuals correctly double offsetx = 0;// (b.Board.Width * Hex.Width) / 2; double offsety = 0;// ((b.Board.Height * Hex.PartialHeight) + Hex.BottomHeight) / 2; switch (position) { case EPointPositionOnHex.TopMiddle: result.X = point.X + offsetx + Hex.HalfWidth; result.Y = point.Y + offsety; return result; case EPointPositionOnHex.RightTop: result.X = point.X + offsetx + Hex.Width; result.Y = point.Y + offsety + Hex.BottomHeight; return result; case EPointPositionOnHex.RightBottom: result.X = point.X + offsetx + Hex.Width; result.Y = point.Y + offsety + Hex.PartialHeight; return result; case EPointPositionOnHex.BottomMiddle: result.X = point.X + offsetx + Hex.HalfWidth; result.Y = point.Y + offsety + Hex.Height; return result; } throw new Exception("Should not reach this"); }