Exemplo n.º 1
0
 public int DistanceTo(SimpleHex dest)
 {
     if (dest == null)
     {
         return(0);
     }
     if (Row == dest.Row)
     {
         return(Math.Abs(dest.Column - Column));
     }
     else if (Column == dest.Column)
     {
         return(Math.Abs(dest.Row - Row));
     }
     else
     {
         var dx = Math.Abs(dest.Row - Row);
         var dy = Math.Abs(dest.Column - Column);
         if (Column < dest.Column)
         {
             return(dx + dy - (int)(Math.Ceiling(dx / 2.0)));
         }
         else
         {
             return(dx + dy - (int)(Math.Floor(dx / 2.0)));
         }
     }
 }
Exemplo n.º 2
0
        private void GetNeighbours()
        {
            for (var i = 0; i < 6; i++)
            {
                var coordinates = AddDelta(Compass.GetCoordinatesFor(ToTuple(), i));

                var newNeighbour = new SimpleHex(Size, coordinates.Item1, coordinates.Item2);

                if (newNeighbour.IsInBounds())
                {
                    Neighbours.Add(newNeighbour);
                }
            }
        }