Settings for the terrain
コード例 #1
0
        /// <summary>
        /// set required data for generating the terrain
        /// </summary>
        public void InitializeSettings(TerrainSettings terrainSettings, GenerationSettings voronoiSettings, GameObject parent, CitySettings citySettings)
        {
            //store settings
            _terrainSettings  = terrainSettings;
            _voronoiSettings  = voronoiSettings;
            _citySettings     = citySettings;
            _parentGameObject = parent;

            //initialize noise
            //if no seed is specified generate a random one
            if (!terrainSettings.UseSeed)
            {
                _terrainSettings.GroundSeed   = Random.Range(int.MinValue, int.MaxValue);
                _terrainSettings.MountainSeed = Random.Range(int.MinValue, int.MaxValue);
                _terrainSettings.TreeSeed     = Random.Range(int.MinValue, int.MaxValue);
                _terrainSettings.DetailSeed   = Random.Range(int.MinValue, int.MaxValue);
            }

            //create noise
            _groundNoise = new PerlinNoise(_terrainSettings.GroundSeed);
            _treeNoise   = new PerlinNoise(_terrainSettings.TreeSeed);
            _detailNoise = new PerlinNoise(_terrainSettings.DetailSeed);

            //calculate total size of 1 terrain tile based on the city bounds
            _terrainSize = (int)(_voronoiSettings.Width * 2f);

            _grassLayers = 0;
            _meshLayers  = 0;

            //create the prototypes used by the generator
            CreatePrototypes();
        }
コード例 #2
0
        /// <summary>
        /// Initialize with required data
        /// </summary>
        public void Initialize(Terrain terrain, CityData cityData, TerrainSettings terrainSettings,
                               GameObject townParent, Dictionary <string, List <GameObject> > prefabs)
        {
            //store data
            _terrain                 = terrain;
            _cityData                = cityData;
            _terrainSettings         = terrainSettings;
            _buildingsPrefabsPerZone = prefabs;

            _townParent = townParent;

            _isInitialized = true;
        }
コード例 #3
0
        /// Generates a voronoi diagram as a basic layout of the town
        public void Generate(GenerationSettings generationSettings, CitySettings citySettings,
                             TerrainSettings terrainSettings)
        {
            //clean up previous generation and build
            Clear();

            //save settings
            GenerationSettings = generationSettings;
            CitySettings       = citySettings;

            //create a parent object at 0,0,0 if none is set
            if (Parent == null)
            {
                Parent = new GameObject("Town");
                Parent.transform.position = Vector3.zero;
            }

            //Generate the city
            GenerateCity();

            //set the terrain settings and build the terrain
            TerrainTileGenerator.InitializeSettings(terrainSettings, GenerationSettings, Parent, CitySettings);
            TerrainTileGenerator.BuildTerrain();

            _bCanBuild = true;

            if (!_bCanBuild)
            {
                Debug.LogWarning("CityGenerator: Unable to build city. \nPlease generate data first!");
                return;
            }

            //Build the town
            _townBuilder.Initialize(TerrainTileGenerator.CityTerrain, _cityData, TerrainTileGenerator.Settings, Parent,
                                    PrefabsPerZone);
            _townBuilder.Build();
        }
コード例 #4
0
 public TerrainEditor(TerrainSettings settings, EditorWindow parentWindow)
 {
     Settings = settings;
     _parentWindow = parentWindow;
 }
コード例 #5
0
 public TerrainEditor(TerrainSettings settings, EditorWindow parentWindow)
 {
     Settings      = settings;
     _parentWindow = parentWindow;
 }
コード例 #6
0
ファイル: TownBuilder.cs プロジェクト: TobieD/City-Generator
        /// <summary>
        /// Initialize with required data
        /// </summary>
        public void Initialize(Terrain terrain, CityData cityData, TerrainSettings terrainSettings,
            GameObject townParent, Dictionary<string, List<GameObject>> prefabs)
        {
            //store data
            _terrain = terrain;
            _cityData = cityData;
            _terrainSettings = terrainSettings;
            _buildingsPrefabsPerZone = prefabs;

            _townParent = townParent;

            _isInitialized = true;
        }
コード例 #7
0
        /// <summary>
        /// set required data for generating the terrain
        /// </summary>
        public void InitializeSettings(TerrainSettings terrainSettings, GenerationSettings voronoiSettings, GameObject parent, CitySettings citySettings)
        {
            //store settings
            _terrainSettings = terrainSettings;
            _voronoiSettings = voronoiSettings;
            _citySettings = citySettings;
            _parentGameObject = parent;

            //initialize noise
            //if no seed is specified generate a random one
            if (!terrainSettings.UseSeed)
            {
                _terrainSettings.GroundSeed = Random.Range(int.MinValue, int.MaxValue);
                _terrainSettings.MountainSeed = Random.Range(int.MinValue, int.MaxValue);
                _terrainSettings.TreeSeed = Random.Range(int.MinValue, int.MaxValue);
                _terrainSettings.DetailSeed = Random.Range(int.MinValue, int.MaxValue);
            }

            //create noise
            _groundNoise = new PerlinNoise(_terrainSettings.GroundSeed);
            _treeNoise = new PerlinNoise(_terrainSettings.TreeSeed);
            _detailNoise = new PerlinNoise(_terrainSettings.DetailSeed);

            //calculate total size of 1 terrain tile based on the city bounds
            _terrainSize = (int)(_voronoiSettings.Width * 2f);

            _grassLayers = 0;
            _meshLayers = 0;

            //create the prototypes used by the generator
            CreatePrototypes();
        }