public void evaluate(int totalCells, float multiplier,int maxBuildings,int minBuildings, mapCell _areaValues) { float densityValue = (neigboringCells/8) + (citySize / totalCells) * 0.5f; densityValue *= multiplier; if(densityValue > maxBuildings) { densityValue = maxBuildings; } if(densityValue < minBuildings) { densityValue = minBuildings; } buildingIndexes = new int[Mathf.RoundToInt(densityValue)]; areaValues = _areaValues; }
//will scan through all feilds that will determine height values and return a normalizewd height value between 0 - 1 public mapCell getMapCell(float x, float z) { float vegDensity = getPerlin(x,z,mapSeeds.veg,vegetationPerlinScale); //the base perlin vales prior to modification based on one another float popDensity = getPerlin(x,z,mapSeeds.pop,populationPerlinScale); float height = getPerlin(x,z,mapSeeds.height,heightPerlinScale); bool isOcean = false; height -= (1-vegDensity) / errosionSoftness; //pop growth popDensity -= vegDensity/populationReductionPerFlora; //populations is less comon in heavilty vegetated areas //print(vegDensity+" "+vegDensity+" "+popDensity); height = ((float)getWhiteNoiseAt(x,z) * whiteMix + height) /(1 + whiteMix); if(height < minPopHeight || height > maxPopHeight) //areas to close to the ocean or to high up for population { popDensity =0; } //flatens world at sea level if(height < watterClamp) { isOcean = true; height = watterClamp; //pushes all values to enough to a uniform sea level vegDensity =0; // no sea life popDensity =0; //noone lives in the ocean } mapCell cell =new mapCell(height,vegDensity,popDensity); cell.isWatter = isOcean; return cell; }
public TownStructure() { position = null; buildingIndexes = null; neigboringCells =0; citySize =0; areaValues = null; }