private void TryAddLink()
        {
            // A link be between exactly two polygons.
            if (_intersectedEdges.Count != 2)
            {
                return;
            }

            // A polygon can't connect with itself
            if (_intersectedEdges[0].Polygon == _intersectedEdges[1].Polygon)
            {
                return;
            }
              
            // Can make a connection.
            PolygonLink polyLink = new PolygonLink(
                    _intersectedEdges[0].Polygon,
                    _intersectedEdges[0].Edge,
                    _intersectedEdges[1].Polygon,
                    _intersectedEdges[1].Edge);
            _navMesh.AddLink(polyLink);
            
         
        }
Esempio n. 2
0
        /// <summary>
        /// This function will look up the polygon index right away. 
        /// This could potentially cause problems if the XML has the polygon defs later in the file.
        /// The values should really be cached and it should be done after.
        /// (or thrown in a closure but the C# syntax is a little too messy for that)
        /// </summary>
        /// <param name="xmlReader"></param>
        /// <param name="navMesh"></param>
        private static void LoadSingleLink(XmlTextReader xmlReader, NavMesh navMesh)
        {
            int startPolygonIndex   = -1;
            int startEdgeStart      = -1;
            int startEdgeEnd        = -1;

            int endPolygonIndex = -1;
            int endEdgeStart    = -1;
            int endEdgeEnd      = -1;

            xmlReader.MoveToContent();
            while (xmlReader.Read())
            {
                if ("start" == xmlReader.Name)
                {
                    startPolygonIndex = int.Parse(xmlReader.GetAttribute("polygon"));
                    startEdgeStart = int.Parse(xmlReader.GetAttribute("edgestart"));
                    startEdgeEnd = int.Parse(xmlReader.GetAttribute("edgeend"));   
                }
                else if ("end" == xmlReader.Name)
                {
                    endPolygonIndex = int.Parse(xmlReader.GetAttribute("polygon"));
                    endEdgeStart = int.Parse(xmlReader.GetAttribute("edgestart"));
                    endEdgeEnd = int.Parse(xmlReader.GetAttribute("edgeend"));
                }
                else if ("link" == xmlReader.Name)
                {
                    PolygonLink polygonLink = new PolygonLink(
                        navMesh.PolygonList[startPolygonIndex],
                        new IndexedEdge(startEdgeStart, startEdgeEnd),
                        navMesh.PolygonList[endPolygonIndex],
                        new IndexedEdge(endEdgeStart, endEdgeEnd));
                    navMesh.AddLink(polygonLink);
                    return;
                }
            }
        }
Esempio n. 3
0
 public void AddLink(PolygonLink link)
 {
     _links.Add(link);
 }
Esempio n. 4
0
 public void AddLink(PolygonLink link)
 {
     _links.Add(link);
 }