public void DetectCollisions(List <Airplane> valAirplanes) { foreach (var plane1 in valAirplanes) { foreach (var plane2 in valAirplanes) { var time = DateTime.Compare(plane1._Time, plane2._Time) < 0 ? plane1._Time : plane2._Time; Tuple <Airplane, Airplane> newPair = new Tuple <Airplane, Airplane>(plane1, plane2); SeparationCondition newCondition = new SeparationCondition(time, newPair); if (plane1._tag != plane2._tag) { if (CheckForCollision(plane1, plane2)) { _logfile.LogCollision(new List <string>() { "Timestamp: " + newCondition.Time + " Between plane: " + newCondition.Pair.Item1._tag + "and" + newCondition.Pair.Item2._tag }); Conditions.Add(newCondition); } } if (!newCondition.Equals(Conditions)) { Conditions.Remove(newCondition); } } } }
public bool Equals(SeparationCondition other) { if (string.Equals(this.Pair.Item1._tag, other.Pair.Item1._tag) && string.Equals(this.Pair.Item2._tag, other.Pair.Item2._tag)) { return(true); } return(false); }