public bool HasShadowAt(BoardPoint point)
 {
     return(HasElementAt(point,
                         BoardElement.OtherHeroShadowLadder,
                         BoardElement.OtherHeroShadowLeft,
                         BoardElement.OtherHeroShadowRight,
                         BoardElement.OtherHeroShadowPipeLeft,
                         BoardElement.OtherHeroShadowPipeRight));
 }
        public bool HasElementAt(BoardPoint point, BoardElement element)
        {
            if (point.IsOutOfBoard(Size))
            {
                return(false);
            }

            return(GetElementAt(point) == element);
        }
예제 #3
0
        private IEnumerable <BoardPoint> EnumerateNeighbors(BoardPoint point)
        {
            yield return(point.ShiftLeft());

            yield return(point.ShiftRight());

            yield return(point.ShiftTop());

            yield return(point.ShiftBottom());
        }
        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);
        }
        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();
        }
        public List <BoardPoint> FindAllElements(BoardElement element)
        {
            List <BoardPoint> result = new List <BoardPoint>();

            for (int i = 0; i < Size * Size; i++)
            {
                BoardPoint pt = GetPointByShift(i);

                if (HasElementAt(pt, element))
                {
                    result.Add(pt);
                }
            }

            return(result);
        }
 public BoardElement GetElementAt(BoardPoint point)
 {
     return((BoardElement)BoardString[GetShiftByPoint(point)]);
 }
 private int GetShiftByPoint(BoardPoint point)
 {
     return(point.Y * Size + point.X);
 }
 public bool HasShadowPillAt(BoardPoint point)
 {
     return(GetShadowPillPositions().Contains(point));
 }
 public bool HasPortalAt(BoardPoint point)
 {
     return(GetPortalPositions().Contains(point));
 }
 public bool HasGoldAt(BoardPoint point)
 {
     return(GetGoldPositions().Contains(point));
 }
 public bool HasLadderAt(BoardPoint point)
 {
     return(GetLadderPositions().Contains(point));
 }
 public bool HasWallAt(BoardPoint point)
 {
     return(GetWallPositions().Contains(point));
 }
 public bool HasOtherHeroAt(BoardPoint point)
 {
     return(GetOtherHeroPositions().Contains(point));
 }
 public bool HasEnemyAt(BoardPoint point)
 {
     return(GetEnemyPositions().Contains(point));
 }
 public bool HasElementAt(BoardPoint point, params BoardElement[] elements)
 {
     return(elements.Any(elem => HasElementAt(point, elem)));
 }
예제 #17
0
 private bool HasElementAt(BoardPoint point, params BoardElement[] elements)
 {
     return(elements.Any(elem => HasElementAt(point.X, point.Y, elem)));
 }
 public bool HasPipeAt(BoardPoint point)
 {
     return(GetPipePositions().Contains(point));
 }