Exemplo n.º 1
0
 /// <summary>
 ///     Swaps the axis and re-orients the compass based on turning <see cref="Movement.Left" /> or
 ///     <see cref="Movement.Right" />.
 /// </summary>
 /// <param name="grid">
 ///     A frame from which this <see cref="Position" /> can reference its private reference to the current
 ///     <see cref="Dimension" /> of orientation.
 /// </param>
 /// <param name="clockwise">
 ///     Specifies whether or not this is a clockwise turn. Set to false for
 ///     <see cref="Movement.Left" /> and true for <see cref="Movement.Right" />.
 /// </param>
 private void Turn(Frame grid, bool clockwise)
 {
     if (CurrentAxis == grid.Y)
     {
         CurrentAxis = grid.X;
         Facing.Turn(clockwise);
     }
     else
     {
         CurrentAxis = grid.Y;
         Facing.Turn(clockwise);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the Direction that this Unit would face after receiving a a turn in the given direction
        /// Note that this does not modify the Unit in any way, and should be used for analytic purposes only.
        /// This method takes mirroring into account - use with caution
        /// </summary>
        /// <param name="relative">the RelativeDirection to turn</param>
        /// <returns>the CardinalDirection that this Unit would face after turning</returns>
        public CardinalDirection Turn(RelativeDirection relative)
        {
            var trueDirection = Mirrored ? relative.Mirror() : relative;

            return(Facing.Turn(trueDirection));
        }