public RoadCollection(RoadComponent currentRoad) { collection = new Dictionary <RoadType, RoadComponent>(); placedRoadsByOrder = new List <RoadType>(); RoadType type = currentRoad.GetRoadType(); Add(currentRoad); SetCurrent(type); Place(type); }
public void Add(RoadComponent road) { RoadType type = road.GetRoadType(); if (collection.ContainsKey(type)) { Debug.LogError("RoadCollection:Add: road of this type existed"); return; } collection.Add(type, road); }
private void Initialize() { RoadComponent component = transform.GetChild(0).GetComponent <RoadComponent>(); collection = new RoadCollection(component); int count = transform.childCount; for (int i = 1; i < count; i++) { component = transform.GetChild(i).GetComponent <RoadComponent>(); collection.Add(component); collection.Place(component.GetRoadType()); } }