public Vector3 RandomCellPosition(int newOwnerId) { int randomCell = 0; //TO DO: Change while for a list of available cells do { randomCell = Random.Range(0, cells.Count); } while(cells[randomCell].Available == false); TerrainCell cell = cells[randomCell]; cell.OwnerId = newOwnerId; cell.RenderMap(tilemapTerrain, tilesInitialTerrain); cell.RenderMap(tilemapEnvironment); return(cell.Center); }
void BuildTerrainBase() { numberOfCellsX = Mathf.FloorToInt(mapWidth / cellSize); numberOfCellsY = Mathf.FloorToInt(mapHeight / cellSize); for (int i = 0; i < numberOfCellsX; i++) { for (int j = 0; j < numberOfCellsY; j++) { Vector2 cellPosition = new Vector2(transform.position.x - (mapWidth / 2) + (cellSize / 2) + (cellSize * i), transform.position.y - (mapHeight / 2) + (cellSize / 2) + (cellSize * j)); TerrainCell newCell = new TerrainCell(cells.Count, cellPosition, cellSize, tilemapBuilder, tilesInitialTerrain); newCell.RenderMap(tilemapGround, tileGround); cells.Add(newCell); } } }