Пример #1
0
    public void GenerateRegions()
    {
        List<Vector2> points = new List<Vector2> ();

        dimensions = new Vector2(Map.terrainSize.tileSize, Map.terrainSize.tileSize);

        // 1. generate points
        GeneratePoints (points);

        if (voronoi != null) {
            voronoi.Dispose();
        }

        // 2. generate voronoi regions
        voronoi = new Delaunay.Voronoi (points, new Rect (0, 0, dimensions.x, dimensions.y));

        // 3. relax, to make regions a bit more uniform
        //m_voronoi = m_voronoi.Relax (1);

        // 4a. get sites defining the island boundary
        hullSites = voronoi.GetHullSites ();

        // 4b. get dalaunay boundary
        //m_delaunayHullSegments = m_voronoi.GetHullLineSegments ();

        // 4c. get edges for drawing
        voronoiEdges = voronoi.ComputeVoronoiDiagram ();

        // 5. Initialize additional structure information
        InitSiteData ();

        // force a re-draw
        debugDraw = null;
    }
Пример #2
0
    void OnDrawGizmos()
    {
        if (voronoi == null)
            return;

        if (debugDraw == null) {
            debugDraw = new MapDebugDraw(this);
        }
        //debugDraw.Draw ();
    }