public void ClickSave()
        {
            InitialConfigLoader loader = new InitialConfigLoader();
            InitialConfigurations config = loader.loadInitialConfig();

            List<HighwayConfigurations> newHighwayConfig = new List<HighwayConfigurations>();

            for (int i = 0; i < config.highwayConfig.Count; i++)
            {
                string GOname = "HighwaySkin " + i;
                var skinitem = highwayMenu.transform.Find("Panel").Find("Scroll Rect").Find("Content Panel").Find(GOname).Find("Panel");

                HighwayConfigurations highwayitem = new HighwayConfigurations();

                highwayitem.type = skinitem.Find("Text_Type").GetComponent<Text>().text;
                highwayitem.size = float.Parse(skinitem.Find("InputField_Width").GetComponent<InputField>().text);
                highwayitem.leftSidewalk = skinitem.Find("ToggleLeftSideWalk").GetComponent<Toggle>().isOn;
                highwayitem.rightSidewalk = skinitem.Find("ToggleRightSideWalk").GetComponent<Toggle>().isOn;
                highwayitem.leftSidewalkSize = float.Parse(skinitem.Find("InputField LeftSize").GetComponent<InputField>().text);
                highwayitem.rightSidewalkSize = float.Parse(skinitem.Find("InputField RightSize").GetComponent<InputField>().text);
                highwayitem.materialPath = materialPaths[i];

                if (isTextureChanged[i])
                {
                    Material mat = (Material)Resources.Load(highwayitem.materialPath);
                    byte[] fileData = File.ReadAllBytes(texturePaths[i]);
                    Texture2D tex = new Texture2D(2, 2);
                    tex.LoadImage(fileData);
                    mat.mainTexture = tex;
                    mat.mainTextureScale = new Vector2(5, 1);
                }

                newHighwayConfig.Add(highwayitem);
            }

            config.highwayConfig = newHighwayConfig;
            loader.saveInitialConfig(Path.Combine(Application.persistentDataPath, "ConfigFiles/initialConfig.xml"), config);

            highwayMenu.SetActive(false);
        }
Beispiel #2
0
        public InitialConfigurations fillConfig()
        {
            InitialConfigurations config = new InitialConfigurations();

            //HIGHWAY CONFIGURATIONS
            config.highwayConfig = new List <HighwayConfigurations>();
            string[] highwayTypes = new string[] { "HighwayResidential", "HighwayPrimary", "HighwaySecondary", "HighwayTertiary", "HighwayTertiaryLink",
                                                   "HighwayUnclassified", "HighwayService", "HighwayPath", "HighwayFootway",
                                                   "HighwayPavement", "Railway", "River" };
            float[] highwaySizes = new float[] { 6.0f, 10.0f, 10.0f, 8.0f, 8.0f, 7.0f, 4.0f, 6.0f, 4.0f, 2.0f, 1.5f, 8.0f };

            string[] highwayMaterials = new string[] { "Materials/Highway/Mat_Residential", "Materials/Highway/Mat_Primary",
                                                       "Materials/Highway/Mat_Secondary", "Materials/Highway/Mat_Tertiary", "Materials/Highway/Mat_TertiaryLink", "Materials/Highway/Mat_Unclassified",
                                                       "Materials/Highway/Mat_Service", "Materials/Highway/Mat_Path", "Materials/Highway/Mat_Footway",
                                                       "Materials/Highway/Mat_Pavement", "Materials/Highway/Mat_Railway", "Materials/Highway/Mat_River" };

            for (int k = 0; k < highwayTypes.Length; k++)
            {
                HighwayConfigurations hc = new HighwayConfigurations();
                hc.size         = highwaySizes[k];
                hc.type         = highwayTypes[k];
                hc.materialPath = highwayMaterials[k];
                config.highwayConfig.Add(hc);
            }

            //RIVER CONFIGURATIONS [NOT USED]
            config.riverConfig = new RiverConfigurations();
            config.riverConfig.materialPath = "Materials/River/??";
            config.riverConfig.size         = 6.0f;

            //AREA CONFIGURATIONS [NOT USED]
            config.areaConfig = new AreaConfigurations();
            config.areaConfig.defaultColor = new Vector3(0.3f, 0.3f, 0.3f);

            //BARRIER CONFIGURATIONS
            config.barrierConfig = new List <BarrierConfigurations>();

            float[]  barrierHeight  = new float[] { 2.0f, 1.5f, 15.0f, 3.0f, 2.0f };
            float[]  barrierWidth   = new float[] { 0.1f, 0.3f, 3.0f, 0.3f, 0.5f };
            string[] barrierTypes   = new string[] { "Fence", "Wall", "City Wall", "Retaining Wall", "Default" };
            string[] barrierPrefabs = new string[] { "Materials/Barrier/chainlink", "Materials/Barrier/BrickWall",
                                                     "Materials/Barrier/CityWall", "Materials/Barrier/RetainingWall",
                                                     "Materials/Barrier/Default" };
            for (int k = 0; k < barrierTypes.Length; k++)
            {
                BarrierConfigurations bar = new BarrierConfigurations();
                bar.width  = barrierWidth[k];
                bar.height = barrierHeight[k];
                bar.Path   = barrierPrefabs[k];
                bar.name   = barrierTypes[k];
                config.barrierConfig.Add(bar);
            }

            //BUILDING CONFIGURATIONS
            config.buildingConfig = new BuildingConfigurations();
            config.buildingConfig.defaultColor = new Vector3(0.5f, 0.5f, 0.5f);
            config.buildingConfig.minheight    = 14.0f;
            config.buildingConfig.maxheight    = 18.0f;
            config.buildingConfig.defaultSkins = new List <BuildingMaterial>();

            List <string> skinNames = new List <string>();

            skinNames.Add("White Concrete");
            skinNames.Add("Dark Brick");
            skinNames.Add("Light Brick");
            skinNames.Add("White Concrete 2");
            skinNames.Add("Dark Brick 2");
            skinNames.Add("Antic Stones");
            skinNames.Add("Kiosk");
            //---------------------
            skinNames.Add("White Historic");
            skinNames.Add("Yellow-Orrange Concrete");
            skinNames.Add("Wide Historic");
            skinNames.Add("Old Concrete 2-floor");
            skinNames.Add("Old Stone");
            skinNames.Add("White Stone");
            skinNames.Add("White Concrete 3");
            skinNames.Add("Brick");
            skinNames.Add("Old Concrete with Shop");
            skinNames.Add("Brick 2");
            skinNames.Add("Old Concrete");
            skinNames.Add("Yellow Historic");
            skinNames.Add("Yellow Concrete with Shop");
            skinNames.Add("Brown-White Concrete");
            skinNames.Add("Orange Wide");
            skinNames.Add("White Stone 2");
            skinNames.Add("White Stone Modern");
            skinNames.Add("White Concrete Modern");
            skinNames.Add("Office Type");
            skinNames.Add("White Concrete 4");

            float[] skinSizes = new float[] { 16.0f, 16.0f, 12.0f, 8.0f, 8.0f, 30.0f, 2.0f, 12.0f, 20.0f, 24.0f, 8.0f, 16.0f, 8.0f, 8.0f, 8.0f, 12.0f, 16.0f, 16.0f, 16.0f, 12.0f, 16.0f, 24.0f, 12.0f, 16.0f, 20.0f, 16.0f, 16.0f };

            //float[] skinSizes = new float[] {16.0f,16.0f,12.0f,8.0f,8.0f,30.0f,2.0f};
            List <string> colorTexturePath = new List <string>();

            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture1.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture2.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture3.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture4.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture5.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/towerTexture.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/KioskTexture.jpg");

            List <string> normalTexturePath = new List <string>();

            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building1Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building2Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building3Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building4Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building5Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/NormalMapTower.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/NormalMapKiosk.png");

            List <string> specularTexturePath = new List <string>();

            specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building1Specular.png");
            specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building2Specular.png");
            specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building3Specular.png");
            specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building4Specular.png");
            specularTexturePath.Add("");
            specularTexturePath.Add("");
            specularTexturePath.Add("");


            for (int i = 1; i <= 20; i++)
            {
                colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Buildings/ColorTex/BuildingTexture" + i + "_COLOR.png");
                normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Buildings/NormalTex/BuildingTexture" + i + "_NRM.png");
                specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Buildings/SpecularTex/BuildingTexture" + i + "_SPEC.png");
            }

            for (int k = 0; k < skinNames.Count; k++)
            {
                BuildingMaterial mat = new BuildingMaterial();
                mat.name                = skinNames[k];
                mat.width               = skinSizes[k];
                mat.colorTexturePath    = colorTexturePath[k];
                mat.normalTexturePath   = normalTexturePath[k];
                mat.specularTexturePath = specularTexturePath[k];
                mat.isActive            = true;

                config.buildingConfig.defaultSkins.Add(mat);
            }

            config.buildingConfig.defaultSkins[5].isActive = false;
            config.buildingConfig.defaultSkins[6].isActive = false;

            return(config);
        }
        public InitialConfigurations fillConfig()
        {
            InitialConfigurations config = new InitialConfigurations();

            //HIGHWAY CONFIGURATIONS
            config.highwayConfig = new List<HighwayConfigurations>();
            string[] highwayTypes = new string[] {"HighwayResidential", "HighwayPrimary", "HighwaySecondary", "HighwayTertiary","HighwayTertiaryLink",
                                                  "HighwayUnclassified", "HighwayService", "HighwayPath", "HighwayFootway",
                                                  "HighwayPavement", "Railway", "River"};
            float[] highwaySizes = new float[] {6.0f, 10.0f, 10.0f, 8.0f, 8.0f, 7.0f, 4.0f, 6.0f, 4.0f, 2.0f, 1.5f, 8.0f };

            string[] highwayMaterials = new string[] {"Materials/Highway/Mat_Residential", "Materials/Highway/Mat_Primary",
            "Materials/Highway/Mat_Secondary","Materials/Highway/Mat_Tertiary", "Materials/Highway/Mat_TertiaryLink", "Materials/Highway/Mat_Unclassified",
            "Materials/Highway/Mat_Service", "Materials/Highway/Mat_Path", "Materials/Highway/Mat_Footway",
            "Materials/Highway/Mat_Pavement", "Materials/Highway/Mat_Railway","Materials/Highway/Mat_River" };

            for(int k=0 ; k < highwayTypes.Length ; k++)
            {
                HighwayConfigurations hc = new HighwayConfigurations();
                hc.size = highwaySizes[k];
                hc.type = highwayTypes[k];
                hc.materialPath = highwayMaterials[k];
                config.highwayConfig.Add(hc);
            }

            //RIVER CONFIGURATIONS [NOT USED]
            config.riverConfig = new RiverConfigurations();
            config.riverConfig.materialPath = "Materials/River/??";
            config.riverConfig.size = 6.0f;

            //AREA CONFIGURATIONS [NOT USED]
            config.areaConfig = new AreaConfigurations();
            config.areaConfig.defaultColor = new Vector3(0.3f, 0.3f, 0.3f);

            //BARRIER CONFIGURATIONS
            config.barrierConfig = new List<BarrierConfigurations>();

            float[] barrierHeight = new float[] {2.0f,1.5f,15.0f,3.0f, 2.0f };
            float[] barrierWidth = new float[] { 0.1f,0.3f,3.0f,0.3f, 0.5f };
            string[] barrierTypes = new string[]{"Fence", "Wall", "City Wall", "Retaining Wall", "Default"};
            string[] barrierPrefabs = new string[]{"Materials/Barrier/chainlink", "Materials/Barrier/BrickWall",
                                                   "Materials/Barrier/CityWall", "Materials/Barrier/RetainingWall",
                                                   "Materials/Barrier/Default"};
            for (int k = 0; k < barrierTypes.Length; k++)
            {
                BarrierConfigurations bar = new BarrierConfigurations();
                bar.width = barrierWidth[k];
                bar.height = barrierHeight[k];
                bar.Path = barrierPrefabs[k];
                bar.name = barrierTypes[k];
                config.barrierConfig.Add(bar);
            }

            //BUILDING CONFIGURATIONS
            config.buildingConfig = new BuildingConfigurations();
            config.buildingConfig.defaultColor = new Vector3(0.5f, 0.5f, 0.5f);
            config.buildingConfig.minheight = 14.0f;
            config.buildingConfig.maxheight = 18.0f;
            config.buildingConfig.defaultSkins = new List<BuildingMaterial>();

            List<string> skinNames = new List<string>();
            skinNames.Add("White Concrete");
            skinNames.Add("Dark Brick");
            skinNames.Add("Light Brick");
            skinNames.Add("White Concrete 2");
            skinNames.Add("Dark Brick 2");
            skinNames.Add("Antic Stones");
            skinNames.Add("Kiosk");
            //---------------------
            skinNames.Add("White Historic");
            skinNames.Add("Yellow-Orrange Concrete");
            skinNames.Add("Wide Historic");
            skinNames.Add("Old Concrete 2-floor");
            skinNames.Add("Old Stone");
            skinNames.Add("White Stone");
            skinNames.Add("White Concrete 3");
            skinNames.Add("Brick");
            skinNames.Add("Old Concrete with Shop");
            skinNames.Add("Brick 2");
            skinNames.Add("Old Concrete");
            skinNames.Add("Yellow Historic");
            skinNames.Add("Yellow Concrete with Shop");
            skinNames.Add("Brown-White Concrete");
            skinNames.Add("Orange Wide");
            skinNames.Add("White Stone 2");
            skinNames.Add("White Stone Modern");
            skinNames.Add("White Concrete Modern");
            skinNames.Add("Office Type");
            skinNames.Add("White Concrete 4");

            float[] skinSizes = new float[] { 16.0f, 16.0f, 12.0f, 8.0f, 8.0f,30.0f,2.0f, 12.0f, 20.0f, 24.0f, 8.0f, 16.0f, 8.0f, 8.0f, 8.0f, 12.0f, 16.0f, 16.0f, 16.0f, 12.0f, 16.0f, 24.0f, 12.0f, 16.0f, 20.0f, 16.0f, 16.0f };

            //float[] skinSizes = new float[] {16.0f,16.0f,12.0f,8.0f,8.0f,30.0f,2.0f};
            List<string> colorTexturePath = new List<string>();
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture1.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture2.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture3.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture4.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/buildingTexture5.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/towerTexture.jpg");
            colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/KioskTexture.jpg");

            List<string> normalTexturePath = new List<string>();
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building1Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building2Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building3Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building4Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building5Normal.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/NormalMapTower.png");
            normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/NormalMapKiosk.png");

            List<string> specularTexturePath = new List<string>();
            specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building1Specular.png");
            specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building2Specular.png");
            specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building3Specular.png");
            specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Building/Building4Specular.png");
            specularTexturePath.Add("");
            specularTexturePath.Add("");
            specularTexturePath.Add("");

            for (int i = 1; i <= 20; i++)
            {
                colorTexturePath.Add(Application.dataPath + "/Resources/Textures/Buildings/ColorTex/BuildingTexture" + i + "_COLOR.png");
                normalTexturePath.Add(Application.dataPath + "/Resources/Textures/Buildings/NormalTex/BuildingTexture" + i + "_NRM.png");
                specularTexturePath.Add(Application.dataPath + "/Resources/Textures/Buildings/SpecularTex/BuildingTexture" + i + "_SPEC.png");
            }

            for (int k = 0; k < skinNames.Count; k++)
            {
                BuildingMaterial mat = new BuildingMaterial();
                mat.name = skinNames[k];
                mat.width = skinSizes[k];
                mat.colorTexturePath = colorTexturePath[k];
                mat.normalTexturePath = normalTexturePath[k];
                mat.specularTexturePath = specularTexturePath[k];
                mat.isActive = true;

                config.buildingConfig.defaultSkins.Add(mat);
            }

            config.buildingConfig.defaultSkins[5].isActive = false;
            config.buildingConfig.defaultSkins[6].isActive = false;

            return config;
        }