Пример #1
0
        /// <summary>
        /// Obtains the navigable Delaunay triangulation and instantiates the pathfinder
        /// with it.
        /// </summary>
        void Start()
        {
            Dungeoneer dungeoneer = GameObject.Find("DungeonSummoner").GetComponent <Dungeoneer>();
            Delaunay   graph      = dungeoneer.navigableDelaunay;

            pathfinder = new AStar(graph);
        }
Пример #2
0
        public void Init()
        {
            GameObject  go = new GameObject();
            Dungeoneer  dg = go.AddComponent <Dungeoneer>();
            DungeonType dt = go.AddComponent <DungeonType>();

            dg.currentDungeonType = dt;
            dg.seed = 5;
            dg.initPRNG();
            dg.generateDelaunay();
            dg.generateVoronoi();

            delVerts = dg.dt.vertices.Count;    // v
            delEdges = dg.dt.edges.Count;       // e

            /* For Delaunay triangulations:
             * "In the plane (d = 2), if there are b vertices on the convex
             * hull, then any triangulation of the points has at most
             * 2n − 2 − b triangles, plus one exterior face."
             */
            int delHull = dg.dt.delaunator.hull.Count;

            delFaces = 2 * delVerts - 1 - delHull; // f

            vorVerts = dg.vd.vertices.Count;       // v
            vorEdges = dg.vd.edges.Count;          // e
            vorFaces = dg.vd.sites.Count + 1;      // f (one exterior)
        }