Beispiel #1
0
        public void GenerateTerrain(IHexMap hexMap)
        {
            CalculateDesertArea(hexMap);

            var terrainTypes = new Dictionary <TileTerrainType, int>
            {
                { TileTerrainType.Bosk, 10 },
                { TileTerrainType.Forest, 10 },
                { TileTerrainType.Marsh, 2 },
                { TileTerrainType.GrainField, 2 },
                { TileTerrainType.Orchard, 5 },
                { TileTerrainType.CattleMeadows, 5 },
                { TileTerrainType.CottonField, 5 },
                { TileTerrainType.SheepMeadows, 5 },
                { TileTerrainType.StudFarm, 1 }
            };

            _heightMapGenerator.GenerateHeightMap(hexMap, 5);

            foreach (var tile in hexMap.Where(t => t.TileTerrainType == TileTerrainType.Plain).ToList())
            {
                var y = tile.Position.Y;

                if (IsWithinDesertBelt(y))
                {
                    tile.TileTerrainType = TileTerrainType.Desert;
                    continue;
                }

                if (IsWithinPoleBelt(y, hexMap.Height))
                {
                    tile.TileTerrainType = TileTerrainType.Tundra;
                    continue;
                }

                tile.TileTerrainType = RandomizeTerrain(terrainTypes);
            }
        }
Beispiel #2
0
        public ElevationGrid BuildHeightmapFromGenerator(RenderingContext rc,
                                                         IHeightMapGenerator generator,
                                                         out Bitmap largePerlinImage,
                                                         int x, int z, int h,
                                                         float sx,
                                                         float sz)
        {
            ElevationGrid g;
            Bitmap        noiseBitmap;
            Image         newImage;

            Console.WriteLine("Rendering noise texture (in a shader)");
            noiseBitmap = largePerlinImage = generator.GenerateHeightMap(rc);

            Console.WriteLine("Processed into GDI Bitmap and cropping down to ({0}, {1}) for performace", x, z);
            newImage = noiseBitmap.GetThumbnailImage(x, z, null, IntPtr.Zero); // scale image to make processing easier
            //noiseBitmap.Dispose();
            noiseBitmap = (Bitmap)newImage;

            Console.WriteLine("Going through each depth pixel to generate an ElevationGrid");
            g = BuildHeightmapFromTexture(sx, sz, noiseBitmap, h);

            return(g);
        }