public List <float[, ]> GenerateMap(CityManager city) { aWidth = width + 1; aHeight = height + 1; map = new List <float[, ]>(); for (int x = 0; x < 11; x++) { map.Add(new float[aWidth, aHeight]); } cityPoints = new CityPoint[aWidth, aHeight]; cityTiles = new CitySquare[width, height]; halfHeight = aHeight / 2f; halfWidth = aWidth / 2f; //RandomFillMap(); if (useRandomSeed) { seed = Time.time.ToString(); } System.Random pseudoRandom = new System.Random(seed.GetHashCode()); for (int i = 0; i < heightNoisePasses; i++) { BuildMapAtIndex(0, heightScale * Mathf.Pow(heightLacunarity, (float)i), Mathf.Pow(heightPersistence, i), pseudoRandom, heightOffset); } for (int i = 0; i < fertilityNoisePasses; i++) { BuildMapAtIndex(1, fertilityScale * Mathf.Pow(fertilityLacunarity, (float)i), Mathf.Pow(fertilityPersistence, i), pseudoRandom, fertilityOffset); } SmoothMap((int)DrawMode.Terain); SmoothMap((int)DrawMode.Fertility); for (int x = 0; x < aWidth; x++) { for (int y = 0; y < aHeight; y++) { cityPoints[x, y] = new CityPoint(map[0][x, y], map[0][x, y]); } } MakeTiles(cityPoints, width, height, scale, vScale, city); Mesh mesh = MeshGenerator.GenerateMesh(scale, vScale, drawMode, cityTiles); GetComponent <MeshFilter>().mesh = mesh; collider.sharedMesh = mesh; return(map); }
public CitySquare( CityPoint[] _corners, float _scale, float _vScale, DrawMode _drawMode, Vector3 _offset, CityManager _city ) { ZonedFor = new HashSet <Zoning>(); traffic = 0; HousingValue = 0; ProductivityValue = 0; guid = Guid.NewGuid(); city = _city; hasRoad = false; Neighbors = new HashSet <CitySquare>(); scale = _scale; offset = _offset * scale; drawMode = _drawMode; vScale = _vScale; vertices = new Vector3[4]; corners = new Dictionary <Direction, CityPoint>(); for (int x = 0; x < 4; x++) { CityPoint corner = _corners[x]; corners.Add((Direction)x, corner); Fertility += corner.Fertility; Height += corner.Height; //vertices[x] = new Vector3((x%3 - 1) * unit, Mathf.Lerp(neighbors.h)) } Height /= 4; Fertility /= 4; Height *= vScale; for (int x = 0; x < 4; x++) { vertices[x] = new Vector3( 0, (corners[(Direction)x].Height * vScale), 0 ) + (clockwiseVs[x] * scale + offset); } realEstateValue = 0f; }
void UpdateFromNeighbors(Direction direction, CityPoint newNeighbor) { corners[direction] = newNeighbor; }