当前位置: 首页>>代码示例>>C#>>正文


C# Contact.GetManifold方法代码示例

本文整理汇总了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;
        }
开发者ID:Clancey,项目名称:Castles,代码行数:19,代码来源:GameplayScreen.cs

示例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;
            }
        }
开发者ID:danielselnick,项目名称:Geometric-Replication,代码行数:24,代码来源:BreakableTest.cs

示例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;
        }
开发者ID:PhoenixWright,项目名称:NePlus,代码行数:32,代码来源:PlayerEnemy.cs

示例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;
        }
开发者ID:emre801,项目名称:GameGame,代码行数:82,代码来源:PlayableCharacter.cs

示例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;

        }
开发者ID:badreddine-dlaila,项目名称:PhysicsHelper.UAP,代码行数:13,代码来源:PhysicsUtilities.cs

示例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;
        }
开发者ID:thedamoes,项目名称:Gravitation,代码行数:39,代码来源:NetLink.cs


注:本文中的FarseerPhysics.Dynamics.Contacts.Contact.GetManifold方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。