本文整理汇总了C#中FarseerPhysics类的典型用法代码示例。如果您正苦于以下问题:C# FarseerPhysics类的具体用法?C# FarseerPhysics怎么用?C# FarseerPhysics使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FarseerPhysics类属于命名空间,在下文中一共展示了FarseerPhysics类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCollide
public override void OnCollide(Entity entB, FarseerPhysics.Dynamics.Contacts.Contact contact)
{
if(IsTractored && m_lastCollideTime <= 0.0f) {
if((ActualVelocity - entB.ActualVelocity).Length() > 700.0f) {
if (entB is TakesDamage)
{
((TakesDamage)entB).TakeHit(tractoredDmg);
asteroidHealth -= tractoredDmg;
m_lastCollideTime = timeBetweenCollisions;
Sound.PlayCue("crash", this);
}
else if (IsTractored && (ActualVelocity - entB.ActualVelocity).Length() > 700.0f)
{
asteroidHealth -= tractoredDmg;
m_lastCollideTime = timeBetweenCollisions;
Sound.PlayCue("crash", this);
}
}
if (asteroidHealth <= 0) InstaKill();
}
base.OnCollide(entB, contact);
}
示例2: body_OnCollision
bool body_OnCollision(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
{
if (body.BodyType == BodyType.Static) return true;
Fixture surface;
if (fixtureA.Body == body)
surface = fixtureB;
else
surface = fixtureA;
if (surface.Body.BodyType == BodyType.Static && surface.Shape.MassData.Area > 100)
{
// rotate to contact normal
Vector2 normal = contact.Manifold.LocalNormal;
if (Vector2.Dot(normal, body.LinearVelocity) > 0)
{
return false;
}
isPendingAttach = true;
pendingRotation = (float)Math.Atan2(normal.Y, normal.X);
body.CollidesWith = Category.None;
return false;
}
return true;
}
示例3: Create
public override void Create(FarseerPhysics.Dynamics.World world, float Xoffset)
{
base.Create(world, Xoffset);
_button = FixtureFactory.CreateRectangle(_world, Dimensions.X, Dimensions.Y, 1, Position + new Vector2(Xoffset, 0));
_fixtures.Add(_button);
_fixtures.Last().UserData = this;
}
示例4: OnEnter
private bool OnEnter(FarseerPhysics.Dynamics.Fixture fixtureA, FarseerPhysics.Dynamics.Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
{
Renderer.IsEnabled = false;
RigidBody.Body.Enabled = false;
Trigger.Enabled = false;
playerScript.HasShank = true;
return true;
}
示例5: deadPlayerOnCollision
public bool deadPlayerOnCollision(Fixture one, Fixture two, FarseerPhysics.Dynamics.Contacts.Contact contact)
{
if (two.UserData.ToString() == "Grave" || two.Body.UserData.ToString() == "Grave")
{
return true;
}
return false;
}
示例6: Body_OnCollision
bool Body_OnCollision(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
{
fixtureB.Body.BodyType = BodyType.Dynamic;
if (fixtureB.Body.Mass == 101){
Random rand = new Random();
this.Position = new Vector2(100 + rand.Next(800), 100 + rand.Next(600));
realPosition = Position;
}
return true;
}
示例7: ShouldCollide
// Collide with non-circloid bullets and non-circloid ships.
public override bool ShouldCollide(Entity entB, FarseerPhysics.Dynamics.Fixture fixture, FarseerPhysics.Dynamics.Fixture entBFixture)
{
if (entB is CircloidShip || entB is Boss || entB is Bullet || entB is SputnikShip) return false;
if (entB is TakesDamage && ((TakesDamage) entB).IsFriendly()) {
return false;
}
return true;
}
示例8: Body_OnCollision
/// <summary>
/// Body_OnCollision re-enables jumping capability if on an object
/// </summary>
/// <param name="a_fixtureA">fixture passed in from Body A</param>
/// <param name="a_fixtureB">fixture passed in from Body B</param>
/// <param name="a_contact">Checking contact between fixtures</param>
private bool Body_OnCollision(Fixture a_fixtureA, Fixture a_fixtureB, FarseerPhysics.Dynamics.Contacts.Contact a_contact)
{
if ((string)a_fixtureB.Body.UserData == "platform")
{
m_body.CollisionCategories = Category.None;
m_body.OnCollision -= Body_OnCollision;
return true;
}
return false;
}
示例9: OnCollidedWith
public override bool OnCollidedWith(Fixture f1, UserControlledCharacter character, Fixture f2, FarseerPhysics.Dynamics.Contacts.Contact contact)
{
if (!character.Invulnerable)
{
character.TakeDamage(25, true, true);
Dead = true;
}
return false;
}
示例10: ShouldCollide
public override bool ShouldCollide(Entity entB, FarseerPhysics.Dynamics.Fixture fixture, FarseerPhysics.Dynamics.Fixture entBFixture)
{
if (entB is Bullet) return false; // Don't collide with other bullets.
if (entB == owner) return false;
if (entB is TakesDamage) {
if (((TakesDamage) owner).IsAllied((TakesDamage) entB)) return false;
}
return true;
}
示例11: collision
public override bool collision(Fixture f1, Fixture f2, FarseerPhysics.Dynamics.Contacts.Contact contact)
{
if (f2.CollisionCategories == Category.Cat3)
{
if (!mInvicible && mHealth > 0)
mHealth--;
Console.WriteLine("Health = " + mHealth);
}
return true;
}
示例12: Create
public override void Create(FarseerPhysics.Dynamics.World world, float Xoffset)
{
base.Create(world, Xoffset);
_door = FixtureFactory.CreateRectangle(_world, Dimensions.X, Dimensions.Y, 1000000, Position + new Vector2(Xoffset, 0));
JointFactory.CreateFixedAngleJoint(_world, _door.Body);
_door.Body.BodyType = BodyType.Dynamic;
_fixtures.Add(_door);
_door.Restitution = -1.0f;
_fixtures.Last().UserData = this;
}
示例13: onCollision
public override bool onCollision(Fixture fix1, Fixture fix, FarseerPhysics.Dynamics.Contacts.Contact Contact)
{
if (target.Fixture.Contains(fix))
{
dispose = true;
onHit(this, fix.UserData as Creature);
return true;
}
else
return false;
}
示例14: GroundCollision
bool GroundCollision(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
{
FarseerPhysics.Collision.Manifold man = new FarseerPhysics.Collision.Manifold();
//get collision manifold
contact.GetManifold(out man);
if (man.LocalNormal.X == 0 && man.LocalNormal.Y == 1)
_grounded = true;
return true;
}
示例15: OnCollisionEnter
public override bool OnCollisionEnter(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
{
if (!this.triggered && !this.consumed)
{
if (fixtureB.Body.parent.identity.Equals(this.triggerer))
{
this.triggered = true;
}
}
return false;
}