Пример #1
0
    private static GameObject CreateNode(Springy.Node springyNode, string label)
    {
        var nodeObject = (GameObject)Instantiate(_nodeResource);

        nodeObject.name = label;
        var node = nodeObject.GetComponent <Node>();

        node.springyNode = springyNode;
        node.Label       = label;
        return(nodeObject);
    }
Пример #2
0
        public Edge CreateNewEdge(Node source, Node target, float length)
        {
            if (source.Id == target.Id) {
                throw new ArgumentException("Cannot link a node with itself");
            }
            if (length < 0) {
                throw new ArgumentException("Cannot have negative length");
            }

            Edge edge = new Edge(edges.Count, source, target, length);
            edges.Add(edge);
            return edge;
        }
Пример #3
0
        public bool RemoveNode(Node node)
        {
            if (node == null) {
                throw new ArgumentException("Specified node cannot be null");
            }

            DetachNode(node);
            return nodes.Remove(node);
        }
Пример #4
0
 public bool DetachNode(Node node)
 {
     if (node == null) {
         throw new ArgumentException("Specified node cannot be null");
     }
     // remove all edges connecting this node
     int num_removed = edges.RemoveAll(edge => (edge.Source == node || edge.Target == node));
     return num_removed > 0;
 }
Пример #5
0
        public Node CreateNewNode(float mass = 1)
        {
            if (mass < 0) {
                throw new ArgumentException("Cannot have negative mass");
            }

            Node node = new Node(nodes.Count, mass);
            nodes.Add(node);
            return node;
        }