private void SpawnCar(object sender, EventArgs e) { SimulatingObject o = new SimulatingObject(-50, 100, 0, 1, 50, 10, "Car"); o.OnDestroy += OnObjectDestroy; objects.Add(o); }
private void SpawnEmergencyCar() { SimulatingObject o = new SimulatingObject(70, 0, 2, 1, 1, 1, "EmergencyCar"); o.OnDestroy += OnObjectDestroy; objects.Add(o); }
private bool CheckCollision(SimulatingObject o1, SimulatingObject o2) { if (destroyedObjectsBuffer.Contains(o1) || destroyedObjectsBuffer.Contains(o2)) { return(false); } if (o2.Top > o1.Top && o2.Top < o1.Top + o1.CollisionHeight && o2.Left > o1.Left && o2.Left < o2.Left + o2.CollisionWidth || o1.Top > o2.Top && o1.Top < o2.Top + o2.CollisionHeight && o1.Left > o2.Left && o1.Left < o2.Left + o2.CollisionWidth) { destroyedObjectsBuffer.Add(o1); destroyedObjectsBuffer.Add(o2); return(true); } return(false); }
private void OnObjectDestroy(SimulatingObject o) { objects.Remove(o); }