public void CreatePlanetTilesData(int tileCount) { // Makes 25 the maximum size of a planet at 5x5 tiles tileCount = Mathf.Clamp(tileCount, 1, 25); // Calculate the demensions of the grid int rowCount = Mathf.CeilToInt(Mathf.Sqrt(tileCount)); int remainderRowsCount = tileCount % rowCount; int columnCount = tileCount / rowCount; if (remainderRowsCount > 0) { columnCount += 1; } planetTiles = new PlanetTileData[columnCount, rowCount]; for (int i = 0; i < columnCount; i++) { for (int j = 0; j < rowCount; j++) { if (remainderRowsCount == 0 || i == columnCount - 1 && j < remainderRowsCount) { planetTiles[i, j] = new PlanetTileData(this); } } } }
public void SetPlanetTileData(PlanetTileData data) { planetTileData = data; }