public static void P_Move() { foreach (var p in Peoples) { People.ChangeLeg(p); Move(p); if (p.X < UserPanel.Width / 2 - CurrentRoad.VerticalRoadLeft * 40 - 101 || p.X > UserPanel.Width / 2 + CurrentRoad.VerticalRoadLeft * 40 + 101 || p.Y > UserPanel.Height / 2 + CurrentRoad.HorizontRoadDown * 40 + 101 || p.Y < UserPanel.Height / 2 - CurrentRoad.HorizontRoadUp * 40 - 101) // дописать { Deleter.Add(p); } } }
public static void Update() { CurrentlyCarCount.Text = Cars.Count.ToString(); foreach (var c in Cars) { if (Car.Check(c)) { c.Speed = 0; } else { c.Speed = Car.CanMove(c); if (c.Turn == CTurn.Right) { RightTurn.StartTurn(c); } else if (c.Turn == CTurn.Left) { LeftTurn.StartTurn(c); } } Move(c); if (c.X < -50 || c.X > UserPanel.Width + 50 || c.Y < -50 || c.Y > UserPanel.Height + 50) { Deleter.Add(c); } } if (Deleter.Count != 0) { foreach (var d in Deleter) { if (d is Car) { Cars.Remove((Car)d); } else if (d is People) { Peoples.Remove((People)d); } } } UserPanel.Invalidate(); }
public static void Update() { foreach (var c in Cars) { // Тут у машин меняется знание о цвете светофора if (c.SIDE == 0 || c.SIDE == 2) { Traff_light.Tr_c02 += c.ChangeTraf; } else { Traff_light.Tr_c13 += c.ChangeTraf; } // Тут узнаем, какие машины на перекрестке Road.OnCrossRoad(c); Road.on_cros += c.ChangeCros; c.Check(); c.Move(); if (c.X < -50 || c.X > Picture.Width + 50 || c.Y < -50 || c.Y > Picture.Height + 50) { Deleter.Add(c); } } foreach (var c in CR_cars) { Road.OnCrossRoad(c); Road.on_cros += c.ChangeCros; c.Check(); c.Move(); } if (Deleter.Count != 0) { foreach (Car car in Deleter) { Cars.Remove(car); } } RenderMap(); Picture.Invalidate(); ver = R.Next(1, 6); }