Esempio n. 1
0
 /// <summary>
 /// Determines the coordinates in a desired direction
 /// </summary>
 /// <param name="coord"></param>
 /// <param name="direction"></param>
 /// <returns></returns>
 public static ICoordinates NextCoordinates(ICoordinates coordinates, Direction direction)
 {
     if (coordinates is BoardCoordinates)
     {
         BoardCoordinates board = new BoardCoordinates(coordinates);
         board.Modify(direction);
         if (board.Valid)
         {
             return(board);
         }
         else
         {
             return(new OuterRingCoordinates(board));
         }
     }
     else if (coordinates is OuterRingCoordinates)
     {
         if (direction != Direction.Clockwise && direction != Direction.Counterclockwise)
         {
             direction = ConvertDirection(coordinates as OuterRingCoordinates, direction);
         }
         ICoordinates outer = new OuterRingCoordinates(coordinates);
         outer.Modify(direction);
         return(outer);
     }
     return(null);
 }
Esempio n. 2
0
 public override bool Equals(object obj)
 {
     if (obj is BoardCoordinates)
     {
         BoardCoordinates other = obj as BoardCoordinates;
         return(other.Diagonal == Diagonal && other.Row == Row);
     }
     return(false);
 }
Esempio n. 3
0
 /// <summary>
 /// Determines the direction based upon two coordinates
 /// </summary>
 /// <param name="src">First coordinates object</param>
 /// <param name="dest">Second coordinate object</param>
 /// <returns></returns>
 public static Direction MoveDirection(BoardCoordinates source, BoardCoordinates destination)
 {
     foreach (Direction dir in Enum.GetValues(typeof(Direction)))
     {
         if (Rules.NextCoordinates(source, dir).Equals(destination))
         {
             return(dir);
         }
     }
     return(Direction.None);
 }
Esempio n. 4
0
 /// <summary>
 /// Determines if two coordinates are next to each other
 /// </summary>
 /// <param name="src">First coordinates object</param>
 /// <param name="dest">Second coordinate object</param>
 /// <returns></returns>
 public static bool IsNextTo(BoardCoordinates source, BoardCoordinates destination)
 {
     if (source == null || destination == null)
     {
         return(false);
     }
     foreach (Direction dir in Enum.GetValues(typeof(Direction)))
     {
         if (NextCoordinates(source, dir).Equals(destination))
         {
             return(true);
         }
     }
     return(false);
 }