示例#1
0
        /// <summary>
        /// Receive map style
        /// </summary>
        /// <param name="type"><see cref="MapStyleData.Type"/> of map style</param>
        /// <returns>Map style as <see cref="GameObjectOptions"/></returns>
        /// <exception cref="ArgumentNullException">Thrown when dataset does not contain <see cref="MapStyleData"/>
        /// of given <see cref="MapStyleData.Type"/></exception>
        public GameObjectOptions GetMapStyle(MapStyleData.Type type)
        {
            var styleData = mapStyleData.FirstOrDefault(element => element.StyleType == type);

            if (styleData == null)
            {
                throw new ArgumentNullException(nameof(styleData), $"Style of {type} type does not exist!");
            }

            var style = styleData.GenerateStyle();

            // Terrain style generation
            var terrainStyleBuilder = new TerrainStyle.Builder()
            {
                AlphaMapResolutionMetersPerPixel = alphaMapResolutionMetersPerPixel,
                BaseMapResolutionMetersPerPixel  = baseMapResolutionMetersPerPixel,
                BaseMapDistance = baseMapDistance,
                TerrainLayers   = new List <TerrainLayer>(terrainLayers)
            };

            style.TerrainStyle = terrainStyleBuilder.Build();

            // Segment style with adjustments to the terrain style
            var segmentStyleBuilder = new SegmentStyle.Builder(style.SegmentStyle)
            {
                GameObjectLayer = style.TerrainStyle.TerrainPaintingLayer
            };

            style.SegmentStyle = segmentStyleBuilder.Build();

            // Area water style with adjustments to the terrain style
            var areaWaterStyleBuilder = new AreaWaterStyle.Builder(style.AreaWaterStyle)
            {
                GameObjectLayer = style.TerrainStyle.TerrainPaintingLayer
            };

            style.AreaWaterStyle = areaWaterStyleBuilder.Build();

            // Region style with adjustments to the terrain style
            var regionStyleBuilder = new RegionStyle.Builder(style.RegionStyle)
            {
                GameObjectLayer = style.TerrainStyle.TerrainPaintingLayer
            };

            style.RegionStyle = regionStyleBuilder.Build();

            // Line water style with adjustments to the terrain style
            var lineWaterStyleBuilder = new LineWaterStyle.Builder(style.LineWaterStyle)
            {
                GameObjectLayer = style.TerrainStyle.TerrainPaintingLayer
            };

            style.LineWaterStyle = lineWaterStyleBuilder.Build();

            return(style);
        }
        /// <summary>
        /// Returns a new <see cref="GameObjectOptions"/> instance reflecting the properties on
        /// this component.
        /// </summary>
        private GameObjectOptions CreateGameObjectOptions()
        {
            GameObjectOptions gameObjectOptions = new GameObjectOptions();

            // Terrain style
            TerrainStyle.Builder terrainStyleBuilder = new TerrainStyle.Builder()
            {
                AlphaMapResolutionMetersPerPixel = AlphaMapResolutionMetersPerPixel,
                BaseMapResolutionMetersPerPixel  = BaseMapResolutionMetersPerPixel,
                BaseMapDistance = BaseMapDistance,
                TerrainLayers   = new List <TerrainLayer>(TerrainLayers),
            };
            gameObjectOptions.TerrainStyle = terrainStyleBuilder.Build();

            // Segment style
            SegmentStyle.Builder segmentStyleBuilder = new SegmentStyle.Builder()
            {
                Material             = SegmentMaterial,
                IntersectionMaterial = IntersectionMaterial,
                GameObjectLayer      = gameObjectOptions.TerrainStyle.TerrainPaintingLayer
            };
            gameObjectOptions.SegmentStyle = segmentStyleBuilder.Build();

            // Area water style
            AreaWaterStyle.Builder areaWaterStyleBuilder = new AreaWaterStyle.Builder()
            {
                FillMaterial    = AreaWaterMaterial,
                GameObjectLayer = gameObjectOptions.TerrainStyle.TerrainPaintingLayer
            };
            gameObjectOptions.AreaWaterStyle = areaWaterStyleBuilder.Build();

            // Region style
            RegionStyle.Builder regionStyleBuilder = new RegionStyle.Builder()
            {
                FillMaterial    = RegionMaterial,
                GameObjectLayer = gameObjectOptions.TerrainStyle.TerrainPaintingLayer
            };
            gameObjectOptions.RegionStyle = regionStyleBuilder.Build();

            // Line water style
            LineWaterStyle.Builder lineWaterStyleBuilder = new LineWaterStyle.Builder()
            {
                Material        = LineWaterMaterial,
                GameObjectLayer = gameObjectOptions.TerrainStyle.TerrainPaintingLayer
            };
            gameObjectOptions.LineWaterStyle = lineWaterStyleBuilder.Build();

            // Extruded structure style
            ExtrudedStructureStyle.Builder extrudedStructureStyleBuilder =
                new ExtrudedStructureStyle.Builder()
            {
                RoofMaterial = BuildingMaterial,
                WallMaterial = BuildingMaterial
            };
            gameObjectOptions.ExtrudedStructureStyle = extrudedStructureStyleBuilder.Build();

            // Modeled structure style
            ModeledStructureStyle.Builder modeledStructureStyleBuilder =
                new ModeledStructureStyle.Builder()
            {
                Material = BuildingMaterial
            };
            gameObjectOptions.ModeledStructureStyle = modeledStructureStyleBuilder.Build();

            return(gameObjectOptions);
        }