Пример #1
0
        public void GenLocalMap(int x, int y, bool sides, bool useSeed)
        {
            currentLocalMapX = x;
            currentLocalMapY = y;

            int[,] mapSeeds = new int[3, 3];

            mapSeeds[1, 1] = heightMap[x, y];
            mapSeeds[0, 0] = x == 0 || y == 0 ? 0 : heightMap[x, y];
            mapSeeds[1, 0] = y == 0 ? 0 : heightMap[x, y];
            mapSeeds[0, 1] = x == 0 ? 0 : heightMap[x, y];
            mapSeeds[2, 0] = x == MAPSIZE - 1 || y == 0 ? 0 : heightMap[x, y];
            mapSeeds[0, 2] = y == MAPSIZE - 1 || x == 0 ? 0 : heightMap[x, y];
            mapSeeds[2, 1] = x == MAPSIZE - 1 ? 0 : heightMap[x, y];
            mapSeeds[1, 2] = y == MAPSIZE - 1 ? 0 : heightMap[x, y];
            mapSeeds[2, 2] = x == MAPSIZE - 1 || y == MAPSIZE - 1 ? 0 : heightMap[x, y];

            int seed = -1;
            if (useSeed && !localMapSeeds.TryGetValue(new Vector2(x, y), out seed))
            {
                Random r = new Random();
                seed = r.Next();
                localMapSeeds.Add(new Vector2(x, y), seed);
            }

            MidPntDisplmnt disp = new MidPntDisplmnt(ref currentLocalMap, 1f, mapSeeds, seed);

            if (sides)
                disp.SetBorderAction(localBorderAction);

            disp.Generate();

            int[,] border = new int[4, MAPSIZE];

            for (int i = 0; i < MAPSIZE; i++)
            {
                border[0, i] = currentLocalMap[0, i];
                border[1, i] = currentLocalMap[i, 0];
                border[2, i] = currentLocalMap[MAPSIZE - 1, i];
                border[3, i] = currentLocalMap[i, MAPSIZE - 1];
            }

            if (!localMapBorder.ContainsKey(new Vector2(x, y)))
                localMapBorder.Add(new Vector2(x, y), border);
        }
Пример #2
0
 public void GenWater()
 {
     int[,] heightmap = new int[Map.MAPSIZE, Map.MAPSIZE];
     int[,] seedval = new int[3, 3];
     seedval[1, 1] = 150;
     MidPntDisplmnt midpoint = new MidPntDisplmnt(ref heightmap, 1f, seedval, seed);
     midpoint.Generate();
     foreach (Voronoi.Center c in cells.Centers.Values)
     {
         c.Properties.Add("Land", heightmap[(int)(c.position.X * 513), (int)(c.position.Y * 513)] > 75);
         c.Properties.Add("Lake", true);
         foreach (Voronoi.Corner corn in c.corners.Values)
         {
             if (!corn.Properties.ContainsKey("Land"))
             {
                 corn.Properties.Add("Land", c.Properties["Land"]);
                 corn.Properties.Add("Lake", true);
             }
         }
     }
     setOcean(cells.Centers[minPos]);
 }
Пример #3
0
        public void GenMap()
        {
            MidPntDisplmnt HeightGen = new MidPntDisplmnt(ref heightMap, 0.750f, -1);
            HeightGen.Generate();

            Erosion erosion = new Erosion(this);
            erosion.Erode();

            RainFall rain = new RainFall(this);
            rain.RainSim();

            BiomeGen biome = new BiomeGen(this);
            biome.GenBiomes();

            //Random r = new Random();
            //int x, y;
            //do
            //{
            //    x = r.Next(0, MAPSIZE);
            //    y = r.Next(0, MAPSIZE);
            //} while (heightMap[x,y] < 25);

            ////localMapSeeds[x, y] = 5;
            ////GenLocalMap(x, y, true, true);
            ////Console.WriteLine("{0}:{1}", x, y);
        }