Example #1
0
        private void RemoveExcludedNodesViaPolygonLayer(NodeNetwork nodeNetwork, MapLayer mapLayer, Dictionary <int, Dictionary <int, PositionedNode> > allNodes)
        {
            ShapeCollection       sc            = this.ToShapeCollection(mapLayer.Name + " nonodes");
            List <PositionedNode> nodesToRemove = GetNodesThatCollideWithShapeCollection(sc, allNodes);

            foreach (var node in nodesToRemove)
            {
                nodeNetwork.Remove(node);
            }
        }
        public static void RemoveNodesForCollision(this NodeNetwork network, AxisAlignedRectangle collision)
        {
            var nodeCircle = new Circle {
                Radius = 20f
            };

            for (var i = network.Nodes.Count - 1; i >= 0; i--)
            {
                var node = network.Nodes[i];
                nodeCircle.Position = node.Position;

                if (collision.CollideAgainst(nodeCircle))
                {
                    network.Remove(node);
                }
            }
            network.UpdateShapes();
        }