本文整理汇总了C#中FarseerPhysics.Dynamics.Contacts.Contact.GetManifold方法的典型用法代码示例。如果您正苦于以下问题:C# Contact.GetManifold方法的具体用法?C# Contact.GetManifold怎么用?C# Contact.GetManifold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FarseerPhysics.Dynamics.Contacts.Contact
的用法示例。
在下文中一共展示了Contact.GetManifold方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BeginContact
public bool BeginContact(Contact contact)
{
Body bodyA = contact.FixtureA.Body;
Body bodyB = contact.FixtureB.Body;
// get the speed of impact between the two bodies
Manifold worldManifold;
contact.GetManifold (out worldManifold);
ManifoldPoint p = worldManifold.Points [0];
Vector2 vA = bodyA.GetLinearVelocityFromLocalPoint (p.LocalPoint);
Vector2 vB = bodyB.GetLinearVelocityFromLocalPoint (p.LocalPoint);
float approachVelocity = Math.Abs (Vector2.Dot (vB - vA, worldManifold.LocalNormal));
//deduct hitpoints from both bodies
ProcessContact (contact, bodyA, approachVelocity);
ProcessContact (contact, bodyB, approachVelocity);
return true;
}
示例2: PostSolve
protected override void PostSolve(Contact contact, ContactConstraint impulse)
{
if (_broke)
{
// The body already broke.
return;
}
// Should the body break?
float maxImpulse = 0.0f;
Manifold manifold;
contact.GetManifold(out manifold);
for (int i = 0; i < manifold.PointCount; ++i)
{
maxImpulse = Math.Max(maxImpulse, impulse.Points[i].NormalImpulse);
}
if (maxImpulse > 40.0f)
{
// Flag the body for breaking.
_break = true;
}
}
示例3: PlayerEnemyOnCollision
private bool PlayerEnemyOnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
{
if (!((fixtureB.CollisionFilter.CollisionCategories & (Category)Global.CollisionCategories.Light) == (Category)Global.CollisionCategories.Light)
&& !((fixtureB.CollisionFilter.CollisionCategories & (Category)Global.CollisionCategories.Enemy) == (Category)Global.CollisionCategories.Enemy))
{
Vector2 down = new Vector2(0.0f, 1.0f);
Manifold manifold;
contact.GetManifold(out manifold);
float angle = Math.Abs(Vector2.Dot(manifold.LocalNormal, down));
if (angle > 0.99f)
{
OnGround = true;
groundCache.Add(fixtureB);
}
if (angle < 0.15f && angle > -0.15f)
{
OnWall = true;
}
}
if ((fixtureB.CollisionFilter.CollisionCategories & (Category)Global.CollisionCategories.PlayerBullet) == (Category)Global.CollisionCategories.PlayerBullet)
{
// decrement enemy health
Health -= 50;
}
return true;
}
示例4: OnCollision
bool OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
{
Vector2 movementBefore = body.LinearVelocity;
body.LinearVelocity = new Vector2(body.LinearVelocity.X, 0);
Block block=null;
foreach (Entity e in game.entities)
{
if (e is Block)
{
Block b = (Block)e;
if(b.fixture.Equals(fixtureB))
{
block = b;
}
}
}
if (contact.IsTouching())
{
if (isMagnet(fixtureB))
return true;
Manifold colis = new Manifold();
contact.GetManifold(out colis);
Vector2 pColis = colis.LocalNormal;
if (pColis.X == 0 && pColis.Y == 1)
{
onGround = true;
modes = Modes.GROUND;
return true;
}
if (pColis.X != 0 && pColis.Y == 0)
{
collisionRec = getBlockFromFixture(fixtureB);
if (fixtureB.Body.Rotation % 45 != 0)
{
onGround = true;
modes = Modes.GROUND;
return false;
}
if (onGround)
{
modes = Modes.WALL;
return false;
}
float direction = inputState.GetJoyDirection();
float x = (float)Math.Sin(direction);
if (pColis.X > 0)
isWallOnRight = true;
else
isWallOnRight = false;
float xMomentum = 0;
if (movementBefore.Y > 0)
{
xMomentum = Math.Abs(body.LinearVelocity.X * 0.3f);
}
else if (movementBefore.Y < 0)
{
xMomentum = -Math.Abs(body.LinearVelocity.X * 0.8f);
}
XboxInput xbi = (XboxInput)inputState;
if (xbi.getYDirection() < 0 || Keyboard.GetState().IsKeyDown(Keys.Up) || Keyboard.GetState().IsKeyDown(Keys.W))
xMomentum += xbi.getYDirection() * 4f;
else
xMomentum = 0;
body.LinearVelocity = new Vector2(0, body.LinearVelocity.Y + xMomentum);
//body.IgnoreGravity = true;
onGround = true;
onGround = true;
modes = Modes.WALL;
ignoreInput = 2;
return false;
}
}
return true;
}
示例5: GetMaxCollisionForce
public static float GetMaxCollisionForce(Contact contact)
{
float maxImpulse = 0.0f;
Manifold manifold;
contact.GetManifold(out manifold);
for (int i = 0; i < manifold.PointCount; ++i)
{
maxImpulse = Math.Max(maxImpulse, manifold.Points[i].NormalImpulse);
}
return maxImpulse;
}
示例6: Body_OnCollision
private bool Body_OnCollision(Fixture fixturea, Fixture fixtureb, Contact contact)
{
if (!Convert.ToString(fixtureb.UserData).Equals("wall") && !Convert.ToString(fixtureb.UserData).Contains("ship"))
{
if (fixtureb.Body.IsBullet)
{
String data = Convert.ToString(fixtureb.UserData);
String[] splitdata = data.Split(':');
String shotType = splitdata[0];
int shotEffect = Convert.ToInt32(splitdata[1]);
switch (shotType)
{
case ("standard"):
{
this.damageTaken += (shotEffect / 2);
break;
}
}
}
}
else
{
if (fixedJoint == null && Convert.ToString(fixtureb.UserData).Contains("ship"))
{
Manifold manifold;
contact.GetManifold(out manifold);
fixedJoint = new DistanceJoint(base.mSpriteBody, fixtureb.Body, new Vector2(0, 0), manifold.Points[0].LocalPoint);
fixedJoint.CollideConnected = true;
mworld.AddJoint(fixedJoint);
}
this.contactMade = true;
}
return true;
}