Пример #1
0
        public bool Contains(GridPosition2D position)
        {
            var arrayPosition = (Point2D)position - Center;

            return(Utilities.IsInInterval(arrayPosition.X, 0, Grid.GetLength(0)) &&
                   Utilities.IsInInterval(arrayPosition.Y, 0, Grid.GetLength(1)));
        }
Пример #2
0
        public BoundedGridField2D <TCell> GetWith(TCell cell, GridPosition2D position)
        {
            var newGrid = (TCell[, ])Grid.Clone();

            position = (GridPosition2D)((Point2D)position - Center);
            newGrid[position.X, position.Y] = cell;
            return(new BoundedGridField2D <TCell>(newGrid, Center));
        }
Пример #3
0
 public TCell this[GridPosition2D position]
 {
     get
     {
         if (!Contains(position))
         {
             throw new ArgumentException(nameof(position));
         }
         var arrayPosition = (Point2D)position - Center;
         return(Grid[arrayPosition.X, arrayPosition.Y]);
     }
 }