Exemplo n.º 1
0
    void Start()
    {
        var grid = new OrientGrid(new Vector3Int(10, 10, 10), 1.01f);

        RandomPatternsTest(grid);
        StartCoroutine(DisplayCubes(grid.GetCells()));
    }
Exemplo n.º 2
0
    void SingleCellTest(OrientGrid grid)
    {
        var index    = new Vector3Int(2, 0, 0);
        var anchor   = new Vector3Int(5, 2, 0);
        var rotation = Quaternion.Euler(0, 0, -190);

        if (grid.TryOrientIndex(index, anchor, rotation, out var rotated))
        {
            var cell = grid.GetCell(rotated);
            cell.Tile = 1;
        }
        else
        {
            Debug.Log("Oriented cell outside grid bounds.");
        }
    }
Exemplo n.º 3
0
    void RandomPatternsTest(OrientGrid grid)
    {
        var lPattern = new Vector3Int[]
        {
            new Vector3Int(0, 0, 0),
            new Vector3Int(1, 0, 0),
            new Vector3Int(2, 0, 0),
            new Vector3Int(0, 1, 0),
            new Vector3Int(0, 2, 0),
            new Vector3Int(0, 3, 0)
        };

        int tryCount   = 0;
        int tilesCount = 0;

        while (tryCount++ < 200)
        {
            if (grid.TryPlacePattern(tilesCount + 1, lPattern, RandomIndex(), RandomRotation()))
            {
                tilesCount++;
            }
        }

        Debug.Log($"{tilesCount} patterns added.");

        Vector3Int RandomIndex()
        {
            int x = Random.Range(0, grid.GridSize.x);
            int y = Random.Range(0, grid.GridSize.y);
            int z = Random.Range(0, grid.GridSize.z);

            return(new Vector3Int(x, y, z));
        }

        Quaternion RandomRotation()
        {
            int x = Random.Range(0, 4) * 90;
            int y = Random.Range(0, 4) * 90;
            int z = Random.Range(0, 4) * 90;

            return(Quaternion.Euler(x, y, z));
        }
    }
Exemplo n.º 4
0
    void PatternTest(OrientGrid grid)
    {
        var lPattern = new Vector3Int[]
        {
            new Vector3Int(0, 0, 0),
            new Vector3Int(1, 0, 0),
            new Vector3Int(2, 0, 0),
            new Vector3Int(0, 1, 0),
            new Vector3Int(0, 2, 0),
            new Vector3Int(0, 3, 0)
        };

        var anchor   = new Vector3Int(2, 8, 0);
        var rotation = Quaternion.Euler(0, 0, -90);

        if (!grid.TryPlacePattern(1, lPattern, anchor, rotation))
        {
            Debug.Log("Pattern outside grid bounds.");
        }
    }
Exemplo n.º 5
0
 public Cell(OrientGrid grid)
 {
     _grid = grid;
 }