コード例 #1
0
        /// <summary><c>HexCoords</c> for the hex at the screen point, with the given AutoScroll position.</summary>
        /// <param name="this"></param>
        /// <param name="point">Screen point specifying hex to be identified.</param>
        /// <param name="autoScroll">AutoScrollPosition for game-display Panel.</param>
        static HexCoords GetHexCoordsInner(this IHexgrid @this, HexPoint point, HexSize autoScroll)
        {
            // Adjust for origin not as assumed by GetCoordinate().
            var grid = new HexSize((int)(@this.GridSizeF().Width *2F / 3F), (int)@this.GridSizeF().Height);

            point -= autoScroll + grid - @this.Margin;

            return(HexCoords.NewCanonCoords(@this.GetCoordinate(@this.MatrixX(), point),
                                            @this.GetCoordinate(@this.MatrixY(), point)));
        }
コード例 #2
0
 /// <summary>Returns the pixel coordinates of the center of the specified hex.</summary>
 /// <param name="this"></param>
 /// <param name="coords"><see cref="HexCoords"/> specification for which pixel center is desired.</param>
 /// <returns>Pixel coordinates of the center of the specified hex.</returns>
 public static HexPoint HexOrigin(this IHexgrid @this, HexCoords coords)
 => new HexPoint(
     (int)(@this.GridSizeF().Width *coords.User.X),
     (int)(@this.GridSizeF().Height *coords.User.Y + @this.GridSizeF().Height / 2 * (coords.User.X + 1) % 2)
     );
コード例 #3
0
 /// <summary>Returns ScrollPosition that places given hex in the upper-Left of viewport.</summary>
 /// <param name="this"></param>
 /// <param name="coordsNewULHex"><c>HexCoords</c> for new upper-left hex</param>
 /// <returns>Pixel coordinates in Client reference frame.</returns>
 static HexPoint HexCenterPointInner(this IHexgrid @this, HexCoords coordsNewULHex)
 => @this.HexOrigin(coordsNewULHex)
 + new HexSize((int)(@this.GridSizeF().Width *2F / 3F), (int)@this.GridSizeF().Height);
コード例 #4
0
 /// <summary><see cref="HexMatrix"/> for 'picking' the <B>Y</B> hex coordinate</summary>
 public static HexMatrix MatrixY(this IHexgrid @this)
 => new HexMatrix(
     0.0F, (3.0F / 2.0F) / @this.GridSizeF().Width,
     2.0F / @this.GridSizeF().Height, 1.0F / @this.GridSizeF().Height, -0.5F, -0.5F);