private bool ExistPair(EntrancesPair p) { foreach (var pair in pairs) { if (pair == p) { return(true); } } return(false); }
public void AddPair(Node a, Node b, IntersectionCentre ic) { if (!a.GetComponent <IntersectionEntrance>()) { IntersectionEntrance ie = a.gameObject.AddComponent <IntersectionEntrance>(); ie.centre = ic; } if (!b.GetComponent <IntersectionEntrance>()) { IntersectionEntrance ie = b.gameObject.AddComponent <IntersectionEntrance>(); ie.centre = ic; } EntrancesPair p = new EntrancesPair(a, b); if (!ExistPair(p)) { pairs.Add(p); } }