void Additions() { while (true) { if (Cars.Count < 6 && r.Next(0, 1000) > 500 && !HasCrash) { Cars.Add(new Car(r.Next(0, 1000) > 500, !CurLight)); LightChangedEvent += Cars.Last().ChangeState; } Thread.Sleep(1000); if (Ppl.Count < 4 && r.Next(0, 1000) > 500 && !HasCrash) { Ppl.Add(new Man(r.Next(0, 1000) > 500, CurLight) { X = r.Next(162, 260) }); LightChangedEvent += Ppl.Last().ChangeState; } Thread.Sleep(1200); } }
public void RemovePerson(Person person) { person.Unsettle(); Ppl.Remove(person); }
void RemoveMan(Man m) { m.CurThread.Abort(); LightChangedEvent -= m.ChangeState; Ppl.Remove(m); }
public void AddPerson(Person person) { Ppl.Add(person); person.Settle(this); }