public static Road CreateNew(Transform parent, Junction j1, Junction j2, float width, bool followGround, float subdivDistance, TerrainGen terrain) { GameObject go = new GameObject(); go.name = "Road"; go.transform.SetParent(parent, false); Road road = go.AddComponent <Road>(); road.Junction1 = j1; road.Junction2 = j2; road.width = width; road.ComputePositioning(); road.subdivs = 2; if (followGround) { road.subdivs = GetSubdivisions(Vector3.Distance(j1.transform.position, j2.transform.position), subdivDistance); } road.GenerateMesh(); if (followGround) { road.FollowGround(terrain); } return(road); }
public bool HasCommonJunction(Road road) { return(road.Junction1 == Junction1 || road.Junction1 == Junction2 || road.Junction2 == Junction1 || road.Junction2 == Junction2); }
public void CreateRoadTo(Junction junc, float width, bool followGround, float subdivDistance, TerrainGen terrain) { Road road = Road.CreateNew(transform.parent, this, junc, width, followGround, subdivDistance, terrain); roads.Add(road); }