Пример #1
0
    public void InitialiseGrid()
    {
        pathFinding.SetGrid(pathingGrid);
        pathFinding.SetPathManager(pathManager);

        pathingGrid.SetGridSize(gridSize);
        pathingGrid.SetupGrid();
        pathingGrid.CreateGrid();
    }
Пример #2
0
    public void GenerateGrid()
    {
        float widthOffset  = 0;
        float lengthOffset = 0;

        if (gridSize.x % 2 == 0)
        {
            widthOffset = 0.5f;
        }

        if (gridSize.y % 2 == 0)
        {
            lengthOffset = 0.5f;
        }

        Vector3 startPoint = new Vector3((-(gridSize.x / 2)) + widthOffset, 0, (-(gridSize.y / 2)) + lengthOffset);

        for (int i = 0; i < gridSize.x; i++)
        {
            NewTile(startPoint, new Vector2(i, 0));

            for (int j = 0; j < gridSize.y - 1; j++)
            {
                startPoint.z++;

                NewTile(startPoint, new Vector2(i, j + 1));
            }

            startPoint.z = (-(gridSize.y / 2)) + lengthOffset;
            startPoint.x++;
        }

        pathFinding.SetGrid(pathingGrid);
        pathFinding.SetPathManager(pathManager);

        pathingGrid.SetGridSize(gridSize);
        pathingGrid.SetupGrid();
        pathingGrid.CreateGrid();
    }