Exemplo n.º 1
0
 /// <summary>
 /// 获取到目标点的邻居节点;
 /// </summary>
 public IEnumerable <CoordPack <RectCoord, RecDirections> > GetNeighbours(RecDirections directions)
 {
     foreach (var direction in GetDirections(directions))
     {
         yield return(new CoordPack <RectCoord, RecDirections>(GetDirection(direction), direction));
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 获取到方向集表示的所有方向;
        /// </summary>
        public static IEnumerable <RecDirections> GetDirections(RecDirections directions)
        {
            int mask = (int)directions;

            for (int intDirection = minDirectionMark; intDirection <= maxDirectionMark; intDirection <<= 1)
            {
                if ((intDirection & mask) == 1)
                {
                    yield return((RecDirections)intDirection);
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 获取到方向偏移量;
 /// </summary>
 public static RectCoord GetDirectionOffset(RecDirections direction)
 {
     return(directionsVector[(int)direction]);
 }
Exemplo n.º 4
0
 /// <summary>
 /// 获取到这个方向的坐标;
 /// </summary>
 public RectCoord GetDirection(RecDirections direction)
 {
     return(this + GetDirectionOffset(direction));
 }