Esempio n. 1
0
File: Road.cs Progetto: yazici/Cigen
    private Dictionary <Intersection, List <Vector3> > intersectionConnectedVertices = new Dictionary <Intersection, List <Vector3> >(); //these are vertices of the road in world space. They are meant to be consumed by each connecting intersection, which converts them into it's own local space to use as vertices for it's own mesh, so everything matches up nicely ;)

    public void Init(Intersection parent, Intersection child, City city)
    {
        if (parent.Position == child.Position)   //sanity check
        {
            Destroy(gameObject);
            return;
        }

        this.parentNode = parent;
        this.childNode  = child;
        this.city       = city;
        this.built      = false;
        this.length     = Vector3.Distance(parentNode.Position, childNode.Position);
        this.direction  = (childNode.Position - parentNode.Position).normalized;

        intersectionConnectedVertices[parentNode] = new List <Vector3>();
        intersectionConnectedVertices[childNode]  = new List <Vector3>();
        BuildMesh();

        parent.AddRoad(this);
        child.AddRoad(this);
        parent.ConnectToIntersection(child);
        city.roads.Add(this);
        transform.parent = city.transform;
    }