示例#1
0
        public static Coordinate Move(this Coordinate coordinates, Compass8Points direction)
        {
            switch (direction)
            {
            case Compass8Points.North: return(coordinates.Up());

            case Compass8Points.NorthEast: return(coordinates.Up().Right());

            case Compass8Points.NorthWest: return(coordinates.Up().Left());

            case Compass8Points.South: return(coordinates.Down());

            case Compass8Points.SouthEast: return(coordinates.Down().Right());

            case Compass8Points.SouthWest: return(coordinates.Down().Left());

            case Compass8Points.East: return(coordinates.Right());

            case Compass8Points.West: return(coordinates.Left());

            default:
                var message = $"Unrecognised direction [{direction}]";
                throw new ArgumentException(message);
            }
        }
示例#2
0
        public static WallDirection ToWallDirection(this Compass8Points direction)
        {
            if (InsideCorners.ContainsKey(direction))
            {
                return(InsideCorners[direction]);
            }

            return(OutsideCorners[direction]);
        }
示例#3
0
        public static bool IsCorner(this Compass8Points surroundingTiles)
        {
            if (surroundingTiles == Compass8Points.Undefined)
            {
                return(false);
            }

            return(OutsideCorners.ContainsKey(surroundingTiles) ||
                   InsideCorners.ContainsKey(surroundingTiles));
        }
示例#4
0
        public static bool IsVertical(this Compass8Points surroundingTiles)
        {
            var isEasterly = ExcludeEasterly.DoesNotHaveTheseDirections(surroundingTiles);

            if (isEasterly)
            {
                return(true);
            }

            var isWesterly = ExcludeWesterly.DoesNotHaveTheseDirections(surroundingTiles);

            return(isWesterly);
        }
示例#5
0
        public static bool IsHorizontal(this Compass8Points surroundingTiles)
        {
            var isSoutherly = ExcludeSoutherly.DoesNotHaveTheseDirections(surroundingTiles);

            if (isSoutherly)
            {
                return(true);
            }

            var isNortherly = ExcludeNortherly.DoesNotHaveTheseDirections(surroundingTiles);

            return(isNortherly);
        }
示例#6
0
 private static bool DoesNotHaveTheseDirections(this Compass8Points source, Compass8Points compare)
 {
     return((source & compare) == Compass8Points.Undefined);
 }