/// <summary>Construct a new Hex instance at location <paramref name="coords"/>.</summary>
 protected Hex(HexCoords coords) : this(coords, 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>
 public static HexPoint HexCenterPoint(this IHexgrid @this, HexCoords coordsNewULHex)
 => @this.IsTransposed ? TransposePoint(@this.HexCenterPointInner(coordsNewULHex))
                       : @this.HexCenterPointInner(coordsNewULHex);
 /// <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)
     );
 /// <summary>TODO</summary>
 public static short?DirectedCost <THex>(BoardStorage <Maybe <THex> > boardHexes, HexCoords hexCoords, Hexside hexside)
     where THex : IHex
 {
     return(boardHexes[hexCoords].Bind(hex => hex.TryStepCost(hexside).ToMaybe()).ToNullable());
 }
 /// <summary>Return the coordinate vector of this hex in the Custom frame.</summary>
 public static IntVector2D UserToCustom(this HexCoords @this)
 {
     return(@this.User * MatrixUserToCustom);
 }
Exemple #6
0
 /// <summary>By default, landmark all four corners and midpoints of all 4 sides.</summary>
 /// <remarks>Pre-processing time on start-up can be reduced by decreasing the number of landmarks,
 /// though at the possible expense of longer path-finding times.</remarks>
 /// <param name="size"></param>
 protected static IFastList <HexCoords> DefaultLandmarks(HexSize size)
 {
     return(new HexPoint[] { new HexPoint(0, 0),
                             new HexPoint(size.Width / 2, 0),
                             new HexPoint(size.Width - 1, 0),
                             new HexPoint(0, size.Height / 2),
                             new HexPoint(size.Width - 1, size.Height / 2),
                             new HexPoint(0, size.Height - 1),
                             new HexPoint(size.Width / 2, size.Height - 1),
                             new HexPoint(size.Width - 1, size.Height - 1) }.Select(p => HexCoords.NewUserCoords(p)).ToFastList());
 }
 /// <summary>TODO</summary>
 public static HexsideCosts ExitCosts <THex>(BoardStorage <Maybe <THex> > boardHexes, HexCoords hexCoords)
     where THex : IHex
 {
     return(new HexsideCosts(hexside => DirectedCost(boardHexes, hexCoords, hexside)));
 }
Exemple #8
0
 /// <inheritdoc/>
 public THex this[HexCoords coords] {
     get { return(_boardHexes[coords]); }
 }
Exemple #9
0
 ///// <summary>TODO</summary>
 //public async Task<ILandmarks> GetLandmarksAsync(System.Threading.CancellationToken token) {
 //    if (_landmarks == null) _landmarks = await LandmarkCollection.CreateLandmarksAsync(this, _landmarkCoords, token);
 //    return _landmarks;
 //}
 /// <inheritdoc/>
 public int  ElevationGroundASL(HexCoords coords)
 {
     return(ElevationBase + this[coords].ElevationLevel * ElevationStep);
 }
Exemple #10
0
 /// <inheritdoc/>
 public virtual Point   ScrollPositionToCenterOnHex(HexCoords coordsNewCenterHex)
 {
     return(HexCenterPoint(HexCoords.NewUserCoords(
                               coordsNewCenterHex.User - (new IntVector2D(Host.VisibleRectangle.Size.User) / 2)
                               )));
 }
Exemple #11
0
 ///<inheritdoc/>
 public override Point HexCenterPoint(HexCoords coordsNewULHex)
 {
     return(TransposePoint(base.HexCenterPoint(coordsNewULHex)));
 }
Exemple #12
0
 /// <summary>Returns whether the hex with <see cref="HexCoords"/> <c>coords</c> is
 /// within the extent of the board.</summary>
 public bool IsOnboard(HexCoords coords)
 {
     return(0 <= coords.User.X && coords.User.X < MapSizeHexes.Width &&
            0 <= coords.User.Y && coords.User.Y < MapSizeHexes.Height);
 }
Exemple #13
0
 public abstract T this[HexCoords coords] {
     get; internal set;
 }
 /// <summary>Construct a new Hex instance at location <paramref name="coords"/>.</summary>
 protected Hex(HexCoords coords, int elevationLevel)
 {
     Coords         = coords;
     ElevationLevel = elevationLevel;
 }
Exemple #15
0
 /// <inheritdoc/>
 public THex Neighbour(HexCoords coords, Hexside hexside)
 {
     return(_boardHexes.Neighbour(coords, hexside));
 }
Exemple #16
0
        /// <inheritdoc/>
        public int  ElevationHexsideASL(HexCoords coords, Hexside hexside)
        {
            var hex = this[coords];

            return(ElevationBase + hex.ElevationLevel * ElevationStep + hex.HeightHexside(hexside));
        }
Exemple #17
0
 /// <inheritdoc/>
 public virtual int  StepCost(HexCoords coords, Hexside hexsideExit)
 {
     return(IsOnboard(coords) ? this[coords].StepCost(hexsideExit) : -1);
 }
Exemple #18
0
 /// <inheritdoc/>
 public int  ElevationTargetASL(HexCoords coords)
 {
     return(ElevationGroundASL(coords) + HeightOfMan);
 }
 /// <summary>Returns a new <see cref="CoordsRectangle"/> from the specified location and dimensions.</summary>
 /// <param name="location">The upper left corner as a <see cref="HexCoords"/> object.</param>
 /// <param name="size">The dimensions as a <see cref="HexCoords"/> object.</param>
 public static CoordsRectangle New(HexCoords location, HexCoords size)
 => new CoordsRectangle(new HexRectangle(location.User, size.User));
Exemple #20
0
 /// <inheritdoc/>
 public int  ElevationObserverASL(HexCoords coords)
 {
     return(ElevationGroundASL(coords) + HeightOfMan);
 }
 /// <summary>TODO</summary>
 public static HexsideCosts EntryCosts <THex>(BoardStorage <Maybe <THex> > boardHexes, HexCoords hexCoords)
     where THex : IHex
 {
     return(new HexsideCosts(hexside => DirectedCost(boardHexes, hexCoords.GetNeighbour(hexside), hexside.Reversed)));
 }
Exemple #22
0
 /// <inheritdoc/>
 public int  ElevationTerrainASL(HexCoords coords)
 {
     return(ElevationGroundASL(coords) + this[coords].HeightTerrain);
 }
 /// <summary>Returns whether the specified hex coordinates are "on" a board of the given dimensions.</summary>
 /// <param name="mapSizeHexes">The hex dimensions of the board.</param>
 /// <param name="hexCoords">The hex coordinates of the hex of interest.</param>
 public static bool IsOnboard(this HexSize mapSizeHexes, HexCoords hexCoords) =>
 mapSizeHexes.IsOnboard(hexCoords.User);
Exemple #24
0
 /// <summary>Perform <paramref name="action"/> for all neighbours of <paramref name="coords"/>.</summary>
 public void ForAllNeighbours(HexCoords coords, Action <THex, Hexside> action)
 {
     _boardHexes.ForAllNeighbours(coords, action);
 }
 /// <summary>Return the coordinate vector of this hex in the User frame.</summary>
 public static HexCoords CustomToUser(this IntVector2D @this)
 {
     return(HexCoords.NewUserCoords(@this * MatrixUserToCustom));
 }
Exemple #26
0
 /// <inheritdoc/>
 public bool IsOnboard(HexCoords coords)
 {
     return(_boardHexes.IsOnboard(coords));
 }
 /// <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);
Exemple #28
0
 /// <inheritdoc/>
 public virtual bool IsPassable(HexCoords coords)
 {
     return(IsOnboard(coords));
 }
 /// <summary>TODO</summary>
 public NeighbourCoords(HexCoords coords, Hexside hexside) : this()
 {
     Coords = coords; Hexside = hexside;
 }
Exemple #30
0
 /// <summary>Returns a new <see cref="CoordsRectangle"/> from the specified location and dimensions.</summary>
 /// <param name="location">The upper left corner as a <see cref="HexCoords"/> object.</param>
 /// <param name="size">The dimensions as a <see cref="HexCoords"/> object.</param>
 public CoordsRectangle(HexCoords location, HexCoords size)
     : this(new HexRectangle(location.User, size.User))
 {
 }