public void RemoveCrate(Crate crate) { if (crate.IsStuck) { World.RemoveJoint(crate.MagnetJoint); } World.RemoveBody(crate.Body); _allGameOjbects.Remove(crate); }
private void AddCrates() { // Define a path that gives the placements of the crates var cratesPath = new Path(); cratesPath.Add(new Vector2(160, 1000)); cratesPath.Add(new Vector2(3500, 1000)); // Split the path into 30 positions - this is where the crates go var positions = cratesPath .SubdivideEvenly(30) .Select(v3 => new Vector2(v3.X, v3.Y)); foreach (var position in positions) { var crate = new Crate(this) { Position = position }; _crates.Add(crate); _allGameOjbects.Add(crate); } }