Example #1
0
        public void ResetGraph()
        {
            Graph        = new SparseGraph <UnityNode, UnityEdge>(false);
            VisitedNodes = new List <UnityNode>();

            Width  = TileWidth * NumTilesX;
            Height = TileHeight * NumTilesY;

            float MidX = TileWidth / 2;
            float MidY = TileHeight / 2;

            for (int Row = 0; Row < NumTilesY; ++Row)
            {
                for (int Col = 0; Col < NumTilesX; ++Col)
                {
                    var NodeIndex = Graph.AddNode(new UnityNode(Graph.GetNextFreeNodeIndex(), new Vector3(MidX + (Col * TileWidth), 0, MidY + (Row * TileWidth))));
                    Graph.Edges.Insert(NodeIndex, new List <UnityEdge>());
                }
            }

            for (int Row = 0; Row < NumTilesY; ++Row)
            {
                for (int Col = 0; Col < NumTilesX; ++Col)
                {
                    AddAllNeighborsToGridNode(Row, Col, NumTilesX, NumTilesY);
                }
            }
        }
Example #2
0
 public NavGraphNode CreateNode()
 {
     return(new NavGraphNode(m_sparseGraph.GetNextFreeNodeIndex(), Vector3.zero));
 }