示例#1
0
        public bool HasElementAt(BoardPoint point, BoardElement element)
        {
            if (point.IsOutOfBoard(Size))
            {
                return(false);
            }

            return(GetElementAt(point) == element);
        }
示例#2
0
        public bool IsNearToElement(BoardPoint point, BoardElement element)
        {
            if (point.IsOutOfBoard(Size))
            {
                return(false);
            }

            return(HasElementAt(point.ShiftBottom(), element) ||
                   HasElementAt(point.ShiftTop(), element) ||
                   HasElementAt(point.ShiftLeft(), element) ||
                   HasElementAt(point.ShiftRight(), element));
        }
示例#3
0
        public int GetCountElementsNearToPoint(BoardPoint point, BoardElement element)
        {
            if (point.IsOutOfBoard(Size))
            {
                return(0);
            }

            //GetHashCode() in classic MS.NET for bool returns 1 for true and 0 for false;
            return(HasElementAt(point.ShiftLeft(), element).GetHashCode() +
                   HasElementAt(point.ShiftRight(), element).GetHashCode() +
                   HasElementAt(point.ShiftTop(), element).GetHashCode() +
                   HasElementAt(point.ShiftBottom(), element).GetHashCode());
        }
示例#4
0
文件: GameBoard.cs 项目: alhenk/snake
        public bool IsNearToElement(BoardPoint point, BoardElement element)
        {
            if (point.IsOutOfBoard(Size))
                return false;

            return HasElementAt(point.ShiftBottom(), element)
                   || HasElementAt(point.ShiftTop(), element)
                   || HasElementAt(point.ShiftLeft(), element)
                   || HasElementAt(point.ShiftRight(), element);
        }
示例#5
0
文件: GameBoard.cs 项目: alhenk/snake
        public bool HasElementAt(BoardPoint point, BoardElement element)
        {
            if (point.IsOutOfBoard(Size))
            {
                return false;
            }

            return GetElementAt(point) == element;
        }
示例#6
0
文件: GameBoard.cs 项目: alhenk/snake
        public int GetCountElementsNearToPoint(BoardPoint point, BoardElement element)
        {
            if (point.IsOutOfBoard(Size))
                return 0;

            //GetHashCode() in classic MS.NET for bool returns 1 for true and 0 for false;
            return HasElementAt(point.ShiftLeft(), element).GetHashCode() +
                   HasElementAt(point.ShiftRight(), element).GetHashCode() +
                   HasElementAt(point.ShiftTop(), element).GetHashCode() +
                   HasElementAt(point.ShiftBottom(), element).GetHashCode();
        }