public void Build() { _dispersion = CellPrefab.Count - 1; var children = _prefabsParent.GetComponentsInChildren <Transform>(); foreach (var child in children) { if (child != _prefabsParent) { DestroyImmediate(child.gameObject); } } var creator = new LandscapeGenerator(_size, _dispersion, _scale, _seed); creator.Build(); for (int x = 0; x < _size.x; x++) { for (int y = 0; y < _size.y; y++) { Debug.Log(creator.HeightMap[x, y]); var position = new Vector3(x, creator.HeightMap[x, y], y); if (CellPrefab[creator.HeightMap[x, y]] != null) { var cell = Instantiate(CellPrefab[creator.HeightMap[x, y]], position, Quaternion.identity); cell.transform.parent = _prefabsParent; } } } }
private void Generate() { var luxor = _entityResolver.EntityBySymbol <ICharacter>("CH_LUXOR"); if (luxor == null) { return; } var currentLoc = luxor.Location + Direction.South; var looking = Direction.North; // luxor.Looking; var lookAmount = (float)(looking - 1) * Landscaping.DirAmount; if (lookAmount > Landscaping.FullWidth) { lookAmount -= Landscaping.FullWidth; } var options = new LandscapeOptions { Here = currentLoc, TimeOfDay = luxor.Time, LookAmount = lookAmount, CurrentDirection = looking, CurrentLocation = luxor.Location, AheadLocation = luxor.Location + looking, IsLooking = false, IsMoving = false, IsInTunnel = false, IsLookingDownTunnel = false, IsLookingOutTunnel = false, LookOffsetAdjustment = -512 // centre view in the middle }; _landscapeGenerator.HorizontalOffset = 0; _landscapeGenerator.ViewportWidth = 2048; _landscapeGenerator.Build(options); }