public IEnumerable <IPosition> GetMovements( IPosition pos, int minX = int.MinValue, int minY = int.MinValue, int maxX = int.MaxValue, int maxY = int.MaxValue ) => RelativePositions .Select(s => pos.Add(s)) .Where(w => w.IsInside(minX, minY, maxX, maxY));
public MineButton GetNeighbor(RelativePositions position) { MineButton neighbor = null; switch (position) { case RelativePositions.Bottom: neighbor = board.GetButton(X, Y + 1); break; case RelativePositions.BottomLeft: neighbor = board.GetButton(X - 1, Y + 1); break; case RelativePositions.BottomRight: neighbor = board.GetButton(X + 1, Y + 1); break; case RelativePositions.Left: neighbor = board.GetButton(X - 1, Y); break; case RelativePositions.Right: neighbor = board.GetButton(X + 1, Y); break; case RelativePositions.Top: neighbor = board.GetButton(X, Y - 1); break; case RelativePositions.TopLeft: neighbor = board.GetButton(X - 1, Y - 1); break; case RelativePositions.TopRight: neighbor = board.GetButton(X + 1, Y - 1); break; } return(neighbor); }