Exemple #1
0
    public PathfindingGraph()
    {
        grid              = PathfindingGrid.instance;
        marker            = grid.GetWaypointMarkerPrefab();
        numCellsAcross    = grid.GetCellsAcross();
        numClustersAcross = grid.GetClustersAcross();
        cellSize          = grid.GetCellSize();
        clusterSize       = grid.GetClusterSize();
        gridCapacity      = numCellsAcross * numCellsAcross;

        neighbourOffsetArray    = new NativeArray <int2>(8, Allocator.Persistent);
        neighbourOffsetArray[0] = new int2(-1, 0);
        neighbourOffsetArray[1] = new int2(+1, 0);
        neighbourOffsetArray[2] = new int2(0, -1);
        neighbourOffsetArray[3] = new int2(0, +1);
        neighbourOffsetArray[4] = new int2(-1, -1);
        neighbourOffsetArray[5] = new int2(+1, -1);
        neighbourOffsetArray[6] = new int2(-1, +1);
        neighbourOffsetArray[7] = new int2(+1, +1);

        CreateGraph();

        //for ( int i = 0; i < 500; i++ )
        //Object.Instantiate( marker , new Vector3( edgePathNodePositions[ i ].x * cellSize , 2 , edgePathNodePositions[ i ].y * cellSize ) , Quaternion.identity );
    }
    public PathfindingGraph()
    {
        grid              = PathfindingGrid.instance;
        marker            = grid.GetWaypointMarkerPrefab();
        numCellsAcross    = grid.GetCellsAcross();
        numClustersAcross = grid.GetClustersAcross();
        cellSize          = grid.GetCellSize();
        clusterSize       = grid.GetClusterSize();
        gridCapacity      = numCellsAcross * numCellsAcross;

        neighbourOffsetArray    = new NativeArray <int2>(8, Allocator.Persistent);
        neighbourOffsetArray[0] = new int2(-1, 0);
        neighbourOffsetArray[1] = new int2(+1, 0);
        neighbourOffsetArray[2] = new int2(0, -1);
        neighbourOffsetArray[3] = new int2(0, +1);
        neighbourOffsetArray[4] = new int2(-1, -1);
        neighbourOffsetArray[5] = new int2(+1, -1);
        neighbourOffsetArray[6] = new int2(-1, +1);
        neighbourOffsetArray[7] = new int2(+1, +1);

        CreateGraph();

        /*for ( int i = 0; i < pathKeysPerEdge.Length; i++ )
         * {
         *  int2 pathKey = pathKeysPerEdge[ i ];
         *
         *  if ( pathKey.y - pathKey.x > 0 )
         *  {
         *      Debug.Log( "Number of paths per edge " + ( pathKey.y - pathKey.x ) );
         *
         *      for ( int j = pathKey.x; j < pathKey.y; j++ )
         *      {
         *          int2 pathPositionKey = edgePaths[ j ];
         *          int count = 0;
         *
         *          for ( int k = pathPositionKey.x; k < pathPositionKey.y; k++ )
         *          {
         *              count++;
         *          }
         *
         *          Debug.Log( "PathLength " + count );
         *      }
         *
         *  }
         * }*/

        /*for ( int i = 0; i < edgePathPositions.Length; i++ )
         * {
         *  Object.Instantiate( marker , new Vector3( edgePathPositions[ i ].x , 2 , edgePathPositions[ i ].y ) , Quaternion.identity );
         * }*/
    }