Exemplo n.º 1
0
    public void AddIntersection(Node node, Road road1, Road road2, Segment seg1 = null, Segment seg2 = null, bool coerce = false, Node.Type type = Node.Type.turn)
    {
        UpdatedIntersectionPositions.Add(node.pos());
        if (type == Node.Type.intersection && CheckForIntersection(node.pos()))
        {
            return;
        }
        //Intersection intersection = Instantiate(intersectionPrefab, transform);

        //intersection.transform.position = node.pos();
        node.transform.name = road1.roadName + " and " + road2.roadName;
        //intersection.transform.parent = node.transform;
        nodes.Add(node);
        if (!road1.nodes.Contains(node))
        {
            road1.nodes.Add(node);
        }
        if (!road2.nodes.Contains(node))
        {
            road2.nodes.Add(node);
        }
        if (seg1 != null)
        {
            seg1.AddIntersection(node);
        }
        if (seg2 != null)
        {
            seg2.AddIntersection(node);
        }
        if (seg1 != null && seg2 != null)
        {
            node.Init(new List <Segment> {
                seg1, seg2
            });
        }
        else
        {
            node.Init();
        }
    }