private void DrawHexMap(HexMap map, Func <Coords, Color> colorMethod, Double scale = DEFAULT_SCALE) { Point offset = GetHexagonOffsets(); double x = 0.0; double y = 0.0; for (int i = 0; i < map.Width; i++) { x += scale + offset.X; y = (i % 2 != 0) ? offset.Y : 0.0; for (int j = 0; j < map.Height; j++) { y += (offset.Y * 2); Coords currCoords = new Coords(i, j); MapHexagon newMapHex = CreateHexagon(x, y, colorMethod(currCoords), currCoords); newMapHex.ChangeColor(map.BaseColorAt(currCoords)); MapHexagons.Add(newMapHex); if (map.IsRiverAt(currCoords)) { RiverSegment seg = map.GetMainRiverSegmentAt(currCoords); Hex.Side? entry = seg.EntrySide; Hex.Side? exit = seg.ExitSide; //DrawRiver(x, y, entry, exit, scale); DrawRivers(); } } } }
private MapHexagon CreateHexagon(Double oriX, Double oriY, Color color, Coords mapCoords) { MapHexagon mapHex = new MapHexagon(mapCoords); // Calculate relative coords of points on angles; this only needs to be done once Point offset = GetHexagonOffsets(); double point2x = offset.X; double point2y = offset.Y; // Start point is the upper-leftmost point of the hexagon double x = oriX; double y = oriY; System.Windows.Point Point1 = new System.Windows.Point(x, y); x += Scale; System.Windows.Point Point2 = new System.Windows.Point(x, y); x += point2x; y += point2y; System.Windows.Point Point3 = new System.Windows.Point(x, y); x -= point2x; y += point2y; System.Windows.Point Point4 = new System.Windows.Point(x, y); x -= Scale; System.Windows.Point Point5 = new System.Windows.Point(x, y); x -= point2x; y -= point2y; System.Windows.Point Point6 = new System.Windows.Point(x, y); PointCollection myPointCollection = new PointCollection { Point1, Point2, Point3, Point4, Point5, Point6 }; mapHex.Points = myPointCollection; return(mapHex); }