本文整理汇总了C#中FarseerPhysics.Dynamics.Contacts.Contact类的典型用法代码示例。如果您正苦于以下问题:C# Contact类的具体用法?C# Contact怎么用?C# Contact使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Contact类属于FarseerPhysics.Dynamics.Contacts命名空间,在下文中一共展示了Contact类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeginContact
public bool BeginContact(Contact contact)
{
// If this is a collision between static objects, just disable it.
if (contact.FixtureA.Body.BodyType == BodyType.Static && contact.FixtureB.Body.BodyType == BodyType.Static)
{
return false;
}
if (!contact.FixtureA.IsSensor && !contact.FixtureA.IsSensor)
{
Rigidbody rigidbodyA = contact.FixtureA.Body.UserData.rigidbody;
Rigidbody rigidbodyB = contact.FixtureB.Body.UserData.rigidbody;
// If we have real colliders clashing, one of them must have a rigid body
// I don't dare disabling it though...
if ((rigidbodyA == null) && (rigidbodyB == null))
{
return true;
}
// If both are rigid bodies - none of them must be kinematic
if ((rigidbodyA != null) && (rigidbodyB != null) && rigidbodyA.isKinematic && rigidbodyB.isKinematic)
{
return true;
}
}
beginContacts.Enqueue(new ColliderContact(contact));
return true;
}
示例2: ContactManager
internal ContactManager()
{
ContactList = null;
ContactCount = 0;
OnBroadphaseCollision = AddPair;
}
示例3: PreSolve
private void PreSolve(Contact contact, ref Manifold oldManifold)
{
if ((Flags & DebugViewFlags.ContactPoints) == DebugViewFlags.ContactPoints)
{
Manifold manifold = contact.Manifold;
if (manifold.PointCount == 0)
return;
Fixture fixtureA = contact.FixtureA;
FixedArray2<PointState> state1, state2;
Collision.Collision.GetPointStates(out state1, out state2, ref oldManifold, ref manifold);
FixedArray2<Vector2> points;
Vector2 normal;
contact.GetWorldManifold(out normal, out points);
for (int i = 0; i < manifold.PointCount && _pointCount < MaxContactPoints; ++i)
{
if (fixtureA == null)
_points[i] = new ContactPoint();
ContactPoint cp = _points[_pointCount];
cp.Position = points[i];
cp.Normal = normal;
cp.State = state2[i];
_points[_pointCount] = cp;
++_pointCount;
}
}
}
示例4: BeginFeetContact
private bool BeginFeetContact( Contact contact )
{
if ( contact.FixtureA == mFeet && !contact.FixtureB.IsSensor
|| contact.FixtureB == mFeet && !contact.FixtureA.IsSensor )
++mNumFootContacts;
return true;
}
示例5: Add
public void Add(Contact contact)
{
if (ContactCount >= ContactCapacity)
return;
// Debug.Assert(ContactCount < ContactCapacity);
_contacts[ContactCount++] = contact;
}
示例6: OnCollision
protected override bool OnCollision(Fixture projectile, Fixture collided, Contact contact)
{
if (NoCollide)
return false;
var collidedUnit = (collided.Body.UserData is Unit) ? (Unit)(collided.Body.UserData) : null;
if (collidedUnit != null) {
if (collidedUnit == Owner) {
Owner.ModifyAttackCooldown(-1000f);
Expire();
}
else {
foreach (Aura aura in Auras) {
collidedUnit.AddAura(aura);
}
collidedUnit.Hurt(Damage);
Body.LinearVelocity = Vector2.Zero;
Body.IgnoreGravity = false;
Body.ApplyLinearImpulse(new Vector2((Owner.Position.X - collidedUnit.Position.X)*7, -200));
Body.ApplyTorque(-2000f);
Body.CollidesWith = Category.Cat1 | Category.Cat2;
Body.CollisionCategories = Category.Cat5;
}
}
return false;
}
示例7: CollisionWithEnemy
// Collision handlers
public bool CollisionWithEnemy(Fixture f1, Fixture f2, Contact contact)
{
Vector2 normal;
FixedArray2<Vector2> points;
contact.GetWorldManifold(out normal, out points);
foreach (IGameComponent comp in this.game.Components)
{
GameEnemy enemy = comp as GameEnemy;
if (enemy != null)
{
if (enemy.getFixture() == f2)
{
if ((Math.Abs(normal.Y) > Math.Abs(normal.X)) && (normal.Y < 0)) // The contact is coming from above
{
enemy.Die(); // Uncomment this line if we decide to fix the timing so we dispose after the animation
this.increaseScore(10);
this.Jump();
break;
}
else
{
this.Die();
}
break;
}
}
}
return true;
}
示例8: OnCollision
public virtual bool OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
{
Vector2 normal = Vector2.Zero;
Contact currentContact = contact;
Vector2 nextNormal = Vector2.Zero;
FixedArray2<Vector2> fx; // No idea what that is, but the function wants it
// Iterate through the contacts, summing the normals
do
{
Vector2 vec = Vector2.Zero;
contact.GetWorldManifold(out vec, out fx);
normal += vec;
currentContact = currentContact.Next;
} while (currentContact != null);
if (normal.Y > Y && normal.X == 0)
{
Pressed = true;
_pressing.Add(fixtureB);
}
return true;
}
示例9: onCollision
public bool onCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
{
Torque = -Torque;
_fixtures.Last().Body.AngularVelocity = 0;
return true;
}
示例10: collisionBullet
public Boolean collisionBullet(Fixture fixA, Fixture fixB, Contact contact)
{
if (!isHung)
//je joins la balle a la cible avec un angle strict, et la balle au joueur avec un distance joint
{
Vector2 diff = bullet.FixtureObject.Body.Position - fixB.Body.Position;
//ObjCercle bulletTP = new ObjCercle(diff, radius, 0.0f, worldPhysic, fixB.Body);
//worldPhysic.RemoveBody(bullet.FixtureObject.Body);
//bullet = bulletTP;
//bullet.addDisplayer();
//juncture = new FarseerPhysics.Dynamics.Joints.DistanceJoint(juncturePoint.Body, bullet.FixtureObject.Body, new Vector2(1, 1)/*AnchorPointJuncturePoint*/, new Vector2(1, 1));
//juncture = JointFactory.CreateDistanceJoint(worldPhysic, juncturePoint.Body, bullet.FixtureObject.Body, new Vector2(10,0)/*AnchorPointJuncturePoint*/, new Vector2(10,0));
//worldPhysic.AddJoint(juncture);
//junctureHook = JointFactory. CreateRevoluteJoint(worldPhysic, fixA.Body, fixB.Body, diff);
//junctureHook.MaxImpulse = 3;
//junctureHook.
worldPhysic.RemoveBody(bullet.FixtureObject.Body);
bullet = null;
//bullet.FixtureObject.Body.BodyType = BodyType.Dynamic;
juncture = new FarseerPhysics.Dynamics.Joints.DistanceJoint(juncturePoint.Body, fixB.Body, AnchorPointJuncturePoint, new Vector2(diff.X, diff.Y));
worldPhysic.AddJoint(juncture);
isHung = true;
}
return false;
}
示例11: BodyCollisionEventArgs
public BodyCollisionEventArgs(BodyComponent bodyComponentA, BodyComponent bodyComponentB, Contact contact)
{
BodyComponentA = bodyComponentA;
BodyComponentB = bodyComponentB;
Contact = contact;
IsColliding = true;
}
示例12: EndContact
public void EndContact(Contact contact)
{
if (contact.FixtureA.Body.UserData != null && contact.FixtureB.Body.UserData != null)
{
endContacts.Enqueue(new ColliderContact(contact));
}
}
示例13: OnCollidedWith
public virtual bool OnCollidedWith(Fixture f, UserControlledCharacter obj, Fixture f2, Contact info)
{
if (Engine.CameraLock)
{
Engine.CameraLock = false;
}
return false;
}
示例14: OnCollision
private bool OnCollision( Fixture fixtureA, Fixture fixtureB, Contact contact )
{
if ( !fixtureB.IsSensor && fixtureB.UserData is Flat )
{
var diff = MathHelper.WrapAngle( UpDir.Angle - Rotation );
Rotation = Rotation + diff;
}
return contact.IsTouching;
}
示例15: onCollision
public bool onCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
{
//if (_fixtures.Count > 0 && _fixtures[0].Body.BodyType == BodyType.Static && fixtureB.UserData is Player)
//{
// _fixtures[0].Body.BodyType = BodyType.Dynamic;
// _fixtures[0].Body.SleepingAllowed = false;
//}
return true;
}