public void collisionEventHandler(object sender, CollisionArgs e) { if (e.collidingObject is Ball && ((Ball)e.collidingObject).shotBy == shooter && e.hitObject is Target) { if (!targetsHit.Contains(e.hitObject)) { score += Target.POINTS; targetsHit.Add(e.hitObject); } } }
public void collisionEventHandler(object sender, CollisionArgs e) { IEntityPhysics collidingObject = e.collidingObject; PolarCoordinate collidingObjectPolar = collidingObject.velocity.toPolar(); float newOrigin = bounceAngle(collidingObjectPolar.origin, e.hitObjectAngle); e.collidingObject.boundingBox().translate(new PolarCoordinate(e.penetration, newOrigin).toCartesian()); float newRadius = collidingObjectPolar.radius; newRadius /= PhysicsSettings.COLLISION_SPEED_DIVISOR; collidingObject.velocity = new PolarCoordinate(newRadius, newOrigin).toCartesian(); }
public void collisionEventHandler(object sender, CollisionArgs e) { if (!hit) { if (e.hitObject != null && e.hitObject.Equals(this) && e.collidingObject is Ball) { Ball ball = (Ball)e.collidingObject; if (!ball.isSimulation) { hit = true; color = color.increaseBrightness(80); } } } }
public void collisionEventHandler(object sender, CollisionArgs e) { if (e.collidingObject is Ball && e.collidingObject.Equals(simulatedBall)) { if (e.hitObject != null && e.hitObject is Target) { Target targetHit = (Target)e.hitObject; if (!targetsHit.Contains(targetHit)) { actionValue += Target.POINTS; targetsHit.Add(targetHit); } } } }