Ejemplo n.º 1
0
        public Graph(IEnumerable <Vector2> points, Voronoi voronoi, int width, int height, float lakeThreshold)
        {
            Width  = width;
            Height = height;
            inside = IslandShape.makePerlin();

            BuildGraph(points, voronoi);
            AssignCornerElevations();
            AssignOceanCoastAndLand(lakeThreshold);
            RedistributeElevations();

            AssignPolygonElevations();

            // Determine downslope paths.
            CalculateDownslopes();

            // Determine watersheds: for every corner, where does it flow
            // out into the ocean?
            CalculateWatersheds();

            // Create rivers.
            CreateRivers();

            // Determine moisture at corners, starting at rivers
            // and lakes, but not oceans. Then redistribute
            // moisture to cover the entire range evenly from 0.0
            // to 1.0. Then assign polygon moisture as the average
            // of the corner moisture.
            AssignCornerMoisture();
            RedistributeMoisture();
            AssignPolygonMoisture();

            centers.ForEach(p => p.biome = GetBiome(p));
        }
Ejemplo n.º 2
0
        public void Init(Func <Vector2, bool> checkIsland = null)
        {
            List <uint> colors = new List <uint>();
            var         points = new List <Vector2>();

            for (int i = 0; i < _pointCount; i++)
            {
                colors.Add(0);
                points.Add(new Vector2(
                               UnityEngine.Random.Range(0, Width),
                               UnityEngine.Random.Range(0, Height))
                           );
            }

            for (int i = 0; i < NUM_LLOYD_RELAXATIONS; i++)
            {
                points = Graph.RelaxPoints(points, Width, Height).ToList();
            }

            var voronoi = new Voronoi(points, colors, new Rect(0, 0, Width, Height));

            checkIsland = checkIsland ?? IslandShape.makePerlin();
            Graph       = new Graph(checkIsland, points, voronoi, (int)Width, (int)Height, _lakeThreshold);
        }
Ejemplo n.º 3
0
 public Graph(IEnumerable <Vector2> points, Voronoi voronoi, int width, int height, float lakeThreshold)
 {
     Init(IslandShape.makePerlin(), points, voronoi, width, height, lakeThreshold);
 }