예제 #1
0
        protected static GeneratorEditor PopulateGenSettings()
        {
            var f     = GenDataBase.DataLoader.LoadData("data/GeneratorEditor").AsDef();
            var d     = new GenDataBase(f);
            var model = new GeneratorEditor(d)
            {
                GenObject = d.Root
            };

            model.SaveFields();
            var settings = new GenSettings(d)
            {
                GenObject = CreateGenObject(d.Root, "GenSettings"), HomeDir = "."
            };

            model.GenSettingsList.Add(settings);
            settings.AddBaseFile("Minimal", "Minimal.dcb", "Data", "The simplest definition required by the generator",
                                 ".dcb");
            settings.AddBaseFile("Definition", "Definition.dcb", "Data", "The definition required by the editor", ".dcb");
            var baseFile = settings.AddBaseFile("ProgramDefinition", "ProgramDefinition.dcb", "Data",
                                                "Defines generator editor data models", ".dcb");

            baseFile.AddProfile("GenProfileModel", "GenProfileModel.prf", "Data");
            settings.AddBaseFile("GeneratorEditor", "GeneratorEditor.dcb", "Data",
                                 "Defines generator editor settings data", ".dcb");
            settings.AddFileGroup("Minimal", "Minimal.dcb", "Data", "Definition");
            settings.AddFileGroup("Basic", "Basic.dcb", "Data", "Definition");
            settings.AddFileGroup("Definition", "Definition.dcb", "Data", "Definition");
            settings.AddFileGroup("ProgramDefinition", "ProgramDefinition.dcb", "Data", "Definition");
            settings.AddFileGroup("GeneratorEditor", "GeneratorEditor.dcb", "Data", "Definition");
            settings.AddFileGroup("GeneratorDefinitionModel", "GeneratorDefinitionModel.dcb", "Data",
                                  "ProgramDefinition", "GenProfileModel");
            return(model);
        }
예제 #2
0
        public IGenDataSettings LoadSettingsFromData(GenDataBase data)
        {
            var model = new GeneratorEditor(data)
            {
                GenObject = data.Root
            };

            SaveToDisk = false;
            return(new GeSettings(model));
        }
예제 #3
0
        public IGenDataSettings GetDesignTimeSettings()
        {
            var r        = new GeneratorEditor();
            var settings = new GeSettings(r);

            settings.Check();
            r.GenSettingsList[0].AddFileGroup("Definition", "Definition.dcb", "Data", "Definition");
            settings.FindFileGroup("Definition");
            return(settings);
        }
예제 #4
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        EditorGUILayout.PropertyField(_seed);
        EditorGUILayout.PropertyField(_terrainGen);
        if (!controller.terrainGenerator.CanGenerate())
        {
            TerrainGenerationEditor terEditor = (TerrainGenerationEditor)CreateEditor(controller.terrainGenerator);
            terEditor.ShowMissingGenRequirements();
        }

        EditorGUILayout.PropertyField(_cityGen);
        if (controller.cityGenerator == null)
        {
            cityGenTab = GUILayout.Toolbar(cityGenTab, cityGenNames);
            switch (cityGenTab)
            {
            case 1:
                CityBiomeGenerator gen = CityBiomeGeneratorEditor.CreateRecursiveDetailGenerator(controller);
                // CreateCityGenerator<CityBiomeGenerator>();
                //gen.terrain = controller.terrainGenerator.terrain;
                break;

            case 2:

                PerlinCityGenerator pGen = PerlinCityGeneratorEditor.CreatePerlinCityGenerator(controller);
                //pGen.terrainGenerator = controller.terrainGenerator;
                break;

            case 3:
                LSystemGeneration lGen = CreateCityGenerator <LSystemGeneration>();
                lGen.terrainGenerator = controller.terrainGenerator;
                break;
            }
        }
        else if (!controller.cityGenerator.CanGenerate())
        {
            GeneratorEditor cityEditor = (GeneratorEditor)CreateEditor(controller.cityGenerator);
            cityEditor.ShowMissingGenRequirements();
        }
        else if (controller.terrainGenerator.CanGenerate())
        {
            if (GUILayout.Button("Generate"))
            {
                controller.SetupAndGenerate();
            }
            if (GUILayout.Button("Clear Buildings"))
            {
                while (controller.cityGenerator.transform.childCount > 0)
                {
                    Transform child = controller.cityGenerator.transform.GetChild(0);
                    DestroyImmediate(child.gameObject);
                }
                if (controller.cityGenerator is LSystemGeneration)
                {
                    ((LSystemGeneration)controller.cityGenerator).clearBuildings();
                }
            }
        }
        serializedObject.ApplyModifiedProperties();

        /*
         * if (GUILayout.Button("Save Heightmap"))
         * {
         *  Texture2D tex = controller.terrainGenerator.biomeTexture;
         *  string fileName = Application.persistentDataPath + "/" + tex.name + ".png";
         *  File.WriteAllBytes(fileName, tex.EncodeToPNG());
         *  Debug.Log("Saved to " + fileName);
         * }
         */
    }
예제 #5
0
 /// <summary>
 /// Create a new editor settings object
 /// </summary>
 /// <param name="model"></param>
 public GeSettings(GeneratorEditor model)
 {
     Model = model;
 }