public void Intersect_Intersects_ReturnTrue(int x, int y) { var box = new BoundingBox2D(new Vector2(10, 10), new Size(10, 10)); var result = box.Intersects(new Vector2(x, y)); Assert.That(result, Is.True); }
private void CheckPlatforms(BoundingBox2D playerBox) { foreach (Platform platform in platforms) { BoundingBox2D platformBox = platform.BoundingBox; if (playerBox.Intersects(platformBox)) { player.RegisterPlatformCollision(platform); } } }
private void CheckHazards(BoundingBox2D playerBox) { foreach (Hazard hazard in hazards) { BoundingBox2D hazardBox = hazard.BoundingBox; if (hazard == lastHazard) { if (!lastHazard.Active || !playerBox.Intersects(hazardBox)) { lastHazard = null; } } else if (hazard.Active) { if (playerBox.Intersects(hazardBox)) { lastHazard = hazard; player.RegisterDamage(GetCollisionDirection(playerBox, hazardBox, hazard.Type)); } } } }