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


C# FarseerPhysics类代码示例

本文整理汇总了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);
        }
开发者ID:jwmcglynn,项目名称:TeamQ,代码行数:26,代码来源:Asteroid.cs

示例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;
        }
开发者ID:guozanhua,项目名称:KinectRagdoll,代码行数:30,代码来源:WallPopper.cs

示例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;
        }
开发者ID:Catchouli-old,项目名称:Fariss,代码行数:8,代码来源:Button.cs

示例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;
        }
开发者ID:ErikUggeldahl,项目名称:AlternativeDevelopment2012PrisonBreak,代码行数:9,代码来源:ShankScript.cs

示例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;
        }
开发者ID:Danathus,项目名称:ggj-resurrection-2012,代码行数:9,代码来源:DeadPlayer.cs

示例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;
 }
开发者ID:njustesen,项目名称:2D-Drawing-shooter,代码行数:10,代码来源:Star.cs

示例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;
        }
开发者ID:jwmcglynn,项目名称:TeamQ,代码行数:11,代码来源:ForceField.cs

示例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;
 }
开发者ID:Breadmouth,项目名称:Gravitas,代码行数:16,代码来源:Particle.cs

示例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;
        }
开发者ID:pquinn,项目名称:time-sink,代码行数:10,代码来源:SmallBullet.cs

示例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;
        }
开发者ID:jwmcglynn,项目名称:TeamQ,代码行数:11,代码来源:Bullet.cs

示例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;
        }
开发者ID:Jamsterx1,项目名称:Titan,代码行数:11,代码来源:Player.cs

示例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;
        }
开发者ID:Catchouli-old,项目名称:Fariss,代码行数:11,代码来源:Door.cs

示例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;
 }
开发者ID:DanielWieder,项目名称:Dota-2d,代码行数:11,代码来源:HomingProjectile.cs

示例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;
        }
开发者ID:alclarity,项目名称:SpoonsAdventure,代码行数:11,代码来源:Character.cs

示例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;
 }
开发者ID:Orujimaru,项目名称:Orujin,代码行数:11,代码来源:Trigger.cs


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