本文整理汇总了C#中FarseerPhysics.Dynamics.Contacts.Contact类的典型用法代码示例。如果您正苦于以下问题:C# Contact类的具体用法?C# Contact怎么用?C# Contact使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Contact类属于FarseerPhysics.Dynamics.Contacts命名空间,在下文中一共展示了Contact类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:Joelone,项目名称:FFWD,代码行数:27,代码来源:GameObjectContactProcessor.cs
示例2: ContactManager
internal ContactManager()
{
ContactList = null;
ContactCount = 0;
OnBroadphaseCollision = AddPair;
}
开发者ID:HaKDMoDz,项目名称:Lunar-Development-Kit,代码行数:7,代码来源:ContactManager.cs
示例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;
}
}
}
开发者ID:RCGame,项目名称:FarseerPhysics,代码行数:32,代码来源:DebugViewSilverlight.cs
示例4: BeginFeetContact
private bool BeginFeetContact( Contact contact )
{
if ( contact.FixtureA == mFeet && !contact.FixtureB.IsSensor
|| contact.FixtureB == mFeet && !contact.FixtureA.IsSensor )
++mNumFootContacts;
return true;
}
开发者ID:theLOLflashlight,项目名称:CyberCube,代码行数:7,代码来源:PlayerPhysicsHandlers.cs
示例5: Add
public void Add(Contact contact)
{
if (ContactCount >= ContactCapacity)
return;
// Debug.Assert(ContactCount < ContactCapacity);
_contacts[ContactCount++] = contact;
}
开发者ID:Kyle44,项目名称:Project-Jack,代码行数:7,代码来源:Island.cs
示例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;
}
开发者ID:ndssia,项目名称:Corsair3,代码行数:28,代码来源:DravensAxes.cs
示例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;
}
开发者ID:askjervold,项目名称:limak,代码行数:34,代码来源:GamePlayer.cs
示例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;
}
开发者ID:Catchouli-old,项目名称:Fariss,代码行数:25,代码来源:PressurePad.cs
示例9: onCollision
public bool onCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
{
Torque = -Torque;
_fixtures.Last().Body.AngularVelocity = 0;
return true;
}
开发者ID:Catchouli-old,项目名称:Fariss,代码行数:7,代码来源:BouncySpikeball.cs
示例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;
}
开发者ID:stickman,项目名称:gameBungee,代码行数:29,代码来源:Bullet.cs
示例11: BodyCollisionEventArgs
public BodyCollisionEventArgs(BodyComponent bodyComponentA, BodyComponent bodyComponentB, Contact contact)
{
BodyComponentA = bodyComponentA;
BodyComponentB = bodyComponentB;
Contact = contact;
IsColliding = true;
}
开发者ID:jpgdev,项目名称:JPEngine,代码行数:7,代码来源:BodyComponent.cs
示例12: EndContact
public void EndContact(Contact contact)
{
if (contact.FixtureA.Body.UserData != null && contact.FixtureB.Body.UserData != null)
{
endContacts.Enqueue(new ColliderContact(contact));
}
}
开发者ID:Joelone,项目名称:FFWD,代码行数:7,代码来源:GameObjectContactProcessor.cs
示例13: OnCollidedWith
public virtual bool OnCollidedWith(Fixture f, UserControlledCharacter obj, Fixture f2, Contact info)
{
if (Engine.CameraLock)
{
Engine.CameraLock = false;
}
return false;
}
开发者ID:pquinn,项目名称:time-sink,代码行数:8,代码来源:CameraUnlockTrigger.cs
示例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;
}
开发者ID:theLOLflashlight,项目名称:CyberCube,代码行数:9,代码来源:EnemyPhysicsHandlers.cs
示例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;
}
开发者ID:Catchouli-old,项目名称:Fariss,代码行数:9,代码来源:Spike.cs
示例16: OnCollision
bool OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
{
if (fixtureB.UserData is EnemyBarrier) {
direction.X = -direction.X;
return false;
}
return true;
}
开发者ID:jack-karamanian,项目名称:ShrekGame,代码行数:9,代码来源:Enemy.cs
示例17: OnCollision
protected override bool OnCollision(Fixture fix1, Fixture fix2, Contact contact) {
base.OnCollision(fix1, fix2, contact);
if (contact.IsTouching && contact.Manifold.LocalNormal.Y < 0) {
canJump = true;
isJumping = false;
}
return true;
}
开发者ID:EEwing,项目名称:KappaGame,代码行数:9,代码来源:PlayerModel.cs
示例18: OnCollision
private bool OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
{
if (fixtureB.CollisionCategories == Category.Cat3)
{
fixtureB.Body.Dispose();
System.Diagnostics.Debug.WriteLine("body removed");
}
return true;
}
开发者ID:RiltonF,项目名称:MonogameAsteroids,代码行数:9,代码来源:Border.cs
示例19: HandleCollision
bool HandleCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
{
WeakReference scene_wr = new WeakReference(Set.Scene);
_RenderSet.Scene.Game.AddUpdateEventHandler(this, (sender, e) => {
new BulletCollisionParticle((Scene)scene_wr.Target, PositionX, PositionY).CenterShift();
Derez();
return true;
});
return true;
}
开发者ID:qwook,项目名称:hungry,代码行数:10,代码来源:BasicBullet.cs
示例20: OnCollision
bool OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
{
var crateBody = fixtureB.Body;
var crate = crateBody.UserData as Crate;
if (crate != null)
{
GameWorld.RemoveCrate(crate);
}
return true;
}
开发者ID:925coder,项目名称:NDC2014,代码行数:10,代码来源:LandingZone.cs
注:本文中的FarseerPhysics.Dynamics.Contacts.Contact类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论