Beispiel #1
0
        private void AssertIndexCalculation(GridSize2D gridSize, int x, int y)
        {
            GridCoord2D coord = new GridCoord2D(gridSize, x, y);
            GridCoord2D index = new GridCoord2D(gridSize, coord.Index);

            AssertPoint(coord.Point, index.Point.X, index.Point.Y);
        }
Beispiel #2
0
 public void Set(TCell cell, GridCoord2D coord)
 {
     if (Cells.Length <= coord.Index)
     {
         throw new System.Exception();
     }
     Cells[coord.Index] = cell;
 }
Beispiel #3
0
        public GridAxisIterator2D(EGridAxis2D axis, GridCoord2D startCoord, GridSize2D gridSize)
        {
            Axis       = axis;
            StartIndex = startCoord.Index;

            GridIterator2D iterator = new GridIterator2D(gridSize);

            Step = iterator.Get(axis);
        }
Beispiel #4
0
        public void GridTraversal()
        {
            GridSize2D     size      = new GridSize2D(5, 6);
            GridCoord2D    coord     = new GridCoord2D(size, 3, 3);
            GridIterator2D traversal = new GridIterator2D(size);

            GridCoord2D changed = new GridCoord2D(size, coord.Index + traversal.Y);

            AssertPoint(changed.Point, 3, 4);
            changed = new GridCoord2D(size, coord.Index - traversal.Y);
            AssertPoint(changed.Point, 3, 2);

            changed = new GridCoord2D(size, coord.Index + traversal.X);
            AssertPoint(changed.Point, 4, 3);
            changed = new GridCoord2D(size, coord.Index - traversal.X);
            AssertPoint(changed.Point, 2, 3);
        }
 /// <summary>
 /// Determines if 2 points are equal by comparing their X and Y values
 /// </summary>
 /// <param name="point">The point to compare</param>
 /// <returns></returns>
 public bool Equals(GridCoord2D point)
 {
     return this == point;
 }
Beispiel #6
0
        public void Set(TCell cell, GridPoint2D point)
        {
            GridCoord2D coord = new GridCoord2D(Size, point);

            Set(cell, coord);
        }
Beispiel #7
0
        public void Set(TCell cell, int x, int y)
        {
            GridCoord2D coord = new GridCoord2D(Size, x, y);

            Set(cell, coord);
        }
Beispiel #8
0
 public TCell Get(GridCoord2D coord)
 {
     return(Cells[coord.Index]);
 }
Beispiel #9
0
        public TCell Get(GridPoint2D point)
        {
            GridCoord2D coord = new GridCoord2D(Size, point);

            return(Get(coord));
        }
Beispiel #10
0
        public TCell Get(int x, int y)
        {
            GridCoord2D coord = new GridCoord2D(Size, x, y);

            return(Get(coord));
        }