Exemple #1
0
    public void GenerateGrid(int rows = -1, int columns = -1)
    {
        ClearGrid();

        if (rows > 0)
        {
            m_rows = rows;
        }
        if (columns > 0)
        {
            m_columns = columns;
        }

        m_GridArray = new BaseTile[m_rows, m_columns];

        for (int r = 0; r < m_rows; r++)
        {
            for (int c = 0; c < m_columns; c++)
            {
                GameObject newTile = GameObject.Instantiate(_tilePrefab, GridRoot.transform);
                newTile.name = "Tile " + r + ", " + c;

                BaseTile tile_ref = newTile.GetComponent <BaseTile>();
                tile_ref.InitializeTile(r, c);
                m_GridArray[r, c] = tile_ref;
            }
        }
    }