Ejemplo n.º 1
0
    public GrowingGrid(T defaultValue, T[,] startingGrid, GridAxes axes, int growthIncrement, bool growsOnRead = true, bool growsOnWrite = true)
    {
        _defaultValue    = defaultValue;
        _growthIncrement = growthIncrement;
        _growsOnRead     = growsOnRead;
        _growsOnWrite    = growsOnWrite;

        int xIndex = axes == GridAxes.YX ? 1 : 0;
        int yIndex = axes == GridAxes.YX ? 0 : 1;
        var xRange = new Point(0, startingGrid.GetLength(xIndex) - 1);
        var yRange = new Point(0, startingGrid.GetLength(yIndex) - 1);

        _grid = new Grid <T>(defaultValue, xRange, yRange);

        AddGrid(0, 0, startingGrid, axes);
    }
Ejemplo n.º 2
0
    public static Grid <T> FromArray(T defaultValue, T[,] sourceGrid, GridAxes axes)
    {
        var xRange = new Point(0, 0);
        var yRange = new Point(0, 0);

        if (axes == GridAxes.XY)
        {
            xRange.Y = sourceGrid.GetLength(0);
            yRange.Y = sourceGrid.GetLength(1);
        }
        else
        {
            xRange.Y = sourceGrid.GetLength(1);
            yRange.Y = sourceGrid.GetLength(0);
        }

        var grid = new Grid <T>(defaultValue, xRange, yRange);

        grid.AddGrid(0, 0, sourceGrid, axes);
        return(grid);
    }
Ejemplo n.º 3
0
 public void AddGrid(int leftX, int bottomY, T[,] grid, GridAxes axes)
 {
     if (axes == GridAxes.XY)
     {
         for (int x = 0; x < grid.GetLength(0); x++)
         {
             for (int y = 0; y < grid.GetLength(1); y++)
             {
                 this[x + leftX, y + bottomY] = grid[x, y];
             }
         }
     }
     else
     {
         for (int x = 0; x < grid.GetLength(1); x++)
         {
             for (int y = 0; y < grid.GetLength(0); y++)
             {
                 this[x + leftX, y + bottomY] = grid[y, x];
             }
         }
     }
 }
Ejemplo n.º 4
0
 /// <summary> Checks to see if this Vector3 is between two other Vector3s in 2 axes along a third axes. </summary>
 /// <param name="original"> This Transform. </param>
 /// <param name="bottomLeftBack"> One of the Transforms to compare to this. </param>
 /// <param name="topRightFront"> The other Transform to compare to this. </param>
 /// <param name="axes"> The axes that will be ingored when comparing values. </param>
 /// <returns> Returns true if this Transform is between. </returns>
 public static bool IsBetweenAlongAxis(this Transform original, Transform bottomLeftBack, Transform topRightFront, GridAxes axes)
 {
     return(original.position.IsBetweenAlongAxis(bottomLeftBack.position, topRightFront.position, axes));
 }
Ejemplo n.º 5
0
 /// <summary> Checks to see if this Vector3 is between two other Vector3s in 2 axes along a third axes. </summary>
 /// <param name="original"> This Vector3. </param>
 /// <param name="bottomLeftBack"> One of the Vector3s to compare to this. </param>
 /// <param name="topRightFront"> The other Vector3 to compare to this. </param>
 /// <param name="axes"> The axes that will be ingored when comparing values. </param>
 /// <returns> Returns true if this Vector3 is between. </returns>
 public static bool IsBetweenAlongAxis(this Vector3 original, Vector3 bottomLeftBack, Vector3 topRightFront, GridAxes axes)
 {
     return((axes == GridAxes.x || (bottomLeftBack.x < original.x && original.x < topRightFront.x)) &&
            (axes == GridAxes.y || (bottomLeftBack.x < original.y && original.y < topRightFront.y)) &&
            (axes == GridAxes.y || (bottomLeftBack.z < original.z && original.z < topRightFront.z)));
 }
Ejemplo n.º 6
0
 /// <summary> Determines if this grid is going along a given axis. </summary>
 /// <param name="axis"> The axis to be checked. </param>
 /// <returns> Returns true if this grid is going along the given axis. </returns>
 public bool IsAlongAxis(GridAxes axis)
 {
     return(axis1 == axis || axis2 == axis);
 }
Ejemplo n.º 7
0
 public void AddGrid(int leftX, int bottomY, T[,] grid, GridAxes axes) => _grid.AddGrid(leftX, bottomY, grid, axes);