public Object(Game1 game, CollisionBody collision) { Game = game; Collision = collision; Collision.Parent = this; Velocity = new Vector2(0f); Acceleration = new Vector2(0f); }
public Dictionary <uint, CollisionBody> GetPotentialCollisions(CollisionBody toCheck) { int xMin = 0; int xMax = 0; int yMin = 0; int yMax = 0; if (toCheck.Shape == CollisionBody.ShapeType.Circle) { CircleBody body = (CircleBody)toCheck; xMin = ((int)(Math.Max(body.Position.X - body.Radius / 2, 0)) / tileSize); xMax = (int)(Math.Min(body.Position.X + body.Radius / 2, maxWidth - 1)) / tileSize; yMin = ((int)(Math.Max(body.Position.Y - body.Radius / 2, 0)) / tileSize); yMax = (int)(Math.Min(body.Position.Y + body.Radius / 2, maxHeight - 1)) / tileSize; } else if (toCheck.Shape == CollisionBody.ShapeType.Rectangle) { RectangleBody body = (RectangleBody)toCheck; xMin = ((int)(Math.Max(body.Position.X, 0)) / tileSize); xMax = (int)(Math.Min(body.Position.X + body.Size.X, 49)) / tileSize; yMin = ((int)(Math.Max(body.Position.Y, 0)) / tileSize); yMax = (int)(Math.Min(body.Position.Y + body.Size.Y, 49)) / tileSize; } // Get every possible CollisionBody Dictionary <uint, CollisionBody> potentials = new Dictionary <uint, CollisionBody>(); for (int y = yMin; y <= yMax; y++) { for (int x = xMin; x <= xMax; x++) { foreach (CollisionBody c in Tiles[y * columns + x].Data.Values) { if (!potentials.ContainsKey(c.id)) { potentials.Add(c.id, c); } } } } return(potentials); }
private List <PhysicsGridTile> GetCoveredTiles(CollisionBody toAdd) { int xMin = 0; int xMax = 0; int yMin = 0; int yMax = 0; if (toAdd.Shape == CollisionBody.ShapeType.Circle) { CircleBody body = (CircleBody)toAdd; xMin = ((int)(Math.Max(body.Position.X - body.Radius / 2, 0)) / tileSize); xMax = (int)(Math.Min(body.Position.X + body.Radius / 2, maxWidth - 1)) / tileSize; yMin = ((int)(Math.Max(body.Position.Y - body.Radius / 2, 0)) / tileSize); yMax = (int)(Math.Min(body.Position.Y + body.Radius / 2, maxHeight - 1)) / tileSize; } else if (toAdd.Shape == CollisionBody.ShapeType.Rectangle) { RectangleBody body = (RectangleBody)toAdd; xMin = ((int)(Math.Max(body.Position.X, 0)) / tileSize); xMax = (int)(Math.Min(body.Position.X + body.Size.X, maxWidth - 1)) / tileSize; yMin = ((int)(Math.Max(body.Position.Y, 0)) / tileSize); yMax = (int)(Math.Min(body.Position.Y + body.Size.Y, maxWidth - 1)) / tileSize; } List <PhysicsGridTile> toReturn = new List <PhysicsGridTile>(); for (int y = yMin; y <= yMax; y++) { for (int x = xMin; x <= xMax; x++) { toReturn.Add(Tiles[y * columns + x]); } } return(toReturn); }
public void Remove(CollisionBody body) { Data.Remove(body.id); }
public void Add(CollisionBody body) { Data.Add(body.id, body); }
public Selection(Game1 game, CollisionBody collision) : base(game, collision) { }
public Trash(Game1 game, CollisionBody collision, int trashID) : base(game, collision) { TrashID = trashID; }
public Board(Game1 game, CollisionBody collision) : base(game, collision) { TrashTiles = new List <Trash>(); }