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


C# World.RemoveBody方法代码示例

本文整理汇总了C#中FarseerPhysics.Dynamics.World.RemoveBody方法的典型用法代码示例。如果您正苦于以下问题:C# World.RemoveBody方法的具体用法?C# World.RemoveBody怎么用?C# World.RemoveBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FarseerPhysics.Dynamics.World的用法示例。


在下文中一共展示了World.RemoveBody方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RemoveBodies

        public override void RemoveBodies(World world)
        {
            foreach (var body in _bodies)
                world.RemoveBody(body);

            _bodies.Clear();
        }
开发者ID:HaKDMoDz,项目名称:Zazumo,代码行数:7,代码来源:TerrainPhysics.cs

示例2: Dispose

 /// <summary>
 /// Destroys the physics objects associated with an <see cref="Exit"/> object.
 /// </summary>
 /// <param name="physicsWorld">The physics world.</param>
 public void Dispose(ref World physicsWorld)
 {
     if (physicsWorld != null)
     {
         physicsWorld.RemoveBody(this.physicsBody);
     }
 }
开发者ID:K-Cully,项目名称:SticKart,代码行数:11,代码来源:Exit.cs

示例3: Clear

        /// <summary>
        /// Clears all bullets from all kinds of lists and from the world
        /// </summary>
        /// <param name="world"></param>
        public void Clear(World world)
        {
            try
            {

                foreach (DrawableGameObject d in bullets)
                {
                    world.RemoveBody(d.body);
                }
                bullets.Clear();
                removeList.Clear();
            }
            catch (Exception ex)
            {
                logger.Fatal(ex.Message + "  " + ex.TargetSite + "  " + ex.StackTrace);
            }
        }
开发者ID:settrbrg,项目名称:ethanolpunk,代码行数:21,代码来源:Projectile.cs

示例4: DisposePhysics

 public void DisposePhysics(World world)
 {
     world.RemoveBody(m_Body);
 }
开发者ID:huardca,项目名称:jampack_xna,代码行数:4,代码来源:PhysicsComponent.cs

示例5: Dispose

 /// <summary>
 /// Disposes of the entity's physics body.
 /// </summary>
 /// <param name="physicsWorld">The physics world.</param>
 public void Dispose(ref World physicsWorld)
 {
     if (this.physicsBody != null)
     {
         this.Active = false;
         physicsWorld.RemoveBody(this.physicsBody);
         this.physicsBody = null;
     }
 }
开发者ID:K-Cully,项目名称:SticKart,代码行数:13,代码来源:ScrollingDeath.cs

示例6: OnRemoveFromGame

 protected override void OnRemoveFromGame(World world)
 {
     //TODO: probably not the best place to create the power up
     this.doodadFactory.CreateDoodad(new DoodadPlacement() { DoodadType = DoodadType.PowerUp, Position = this.Position });
     world.RemoveBody(this.sensor);
 }
开发者ID:aschearer,项目名称:BaconGameJam2012,代码行数:6,代码来源:ComputerControlledTank.cs

示例7: Cut

        /// <summary>
        /// This is a high-level function to cuts fixtures inside the given world, using the start and end points.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="start">The startpoint.</param>
        /// <param name="end">The endpoint.</param>
        /// <param name="thickness">The thickness of the cut</param>
        public static void Cut(World world, Vector2 start, Vector2 end, float thickness)
        {
            List<Fixture> fixtures = new List<Fixture>();
            List<Vector2> entryPoints = new List<Vector2>();
            List<Vector2> exitPoints = new List<Vector2>();

            // Get the entry points
            world.RayCast((f, p, n, fr) =>
                              {
                                  fixtures.Add(f);
                                  entryPoints.Add(p);
                                  return 1;
                              }, start, end);

            // Reverse the ray to get the exitpoints
            world.RayCast((f, p, n, fr) =>
                              {
                                  exitPoints.Add(p);
                                  return 1;
                              }, end, start);

            // We only have a single point. We need at least 2
            if (entryPoints.Count + exitPoints.Count < 2)
                return;

            // There should be as many entry as exit points
            if (entryPoints.Count != exitPoints.Count)
            {
                if (entryPoints.Count > exitPoints.Count)
                {
                    entryPoints.RemoveAt(entryPoints.Count - 1);
                    fixtures.RemoveAt(fixtures.Count - 1);
                }

                if (exitPoints.Count > entryPoints.Count)
                {
                    exitPoints.RemoveAt(exitPoints.Count - 1);
                    fixtures.RemoveAt(fixtures.Count - 1);
                }
            }

            for (int i = 0; i < fixtures.Count; i++)
            {
                // can't cut circles yet !
                if (fixtures[i].Shape.ShapeType != ShapeType.Polygon)
                    continue;

                if (fixtures[i].Body.BodyType != BodyType.Static)
                {
                    // Split the shape up into two shapes
                    Vertices first;
                    Vertices second;
                    SplitShape(fixtures[i], entryPoints[i], exitPoints[i], thickness, out first, out second);

                    // Delete the original shape and create two new. Retain the properties of the body.
                    Fixture firstFixture = FixtureFactory.CreatePolygon(world, first, fixtures[i].Density,
                                                                        fixtures[i].Body.Position);
                    firstFixture.Body.BodyType = BodyType.Dynamic;

                    Fixture secondFixture = FixtureFactory.CreatePolygon(world, second, fixtures[i].Density,
                                                                         fixtures[i].Body.Position);
                    secondFixture.Body.BodyType = BodyType.Dynamic;

                    world.RemoveBody(fixtures[i].Body);
                }
            }
        }
开发者ID:seankruer,项目名称:eecs-290-super-power-robots,代码行数:74,代码来源:CuttingTools.cs

示例8: DisposeOfFloor

        /// <summary>
        /// Removes the floor bodies from the world and clears the list.
        /// </summary>
        /// <param name="physicsWorld">The physics world containing the floor.</param>
        /// <param name="floorEdges">The list of floor edge bodies.</param>
        /// <param name="visualFloorEdges">The list of visual floor edges.</param>
        public static void DisposeOfFloor(ref World physicsWorld, ref List<Body> floorEdges, ref List<VisualEdge> visualFloorEdges)
        {
            visualFloorEdges.Clear();
            foreach (Body body in floorEdges)
            {
                physicsWorld.RemoveBody(body);
            }

            floorEdges.Clear();
        }
开发者ID:K-Cully,项目名称:SticKart,代码行数:16,代码来源:LevelFactory.cs

示例9: RemoveBody

 public void RemoveBody(World world)
 {
     world.RemoveBody(this.spriteBody);
     ActivatePhysics(world);
     return;
 }
开发者ID:markadamdixon,项目名称:MapEditor_ProduceWars_CSharp,代码行数:6,代码来源:Sprite.cs

示例10: Remove

 public void Remove(Coin coin, World world)
 {
     world.RemoveBody(coin.Body);
     _coins.Remove(coin);
 }
开发者ID:victorMoneratto,项目名称:infinite-island,代码行数:5,代码来源:Coins.cs

示例11: Initialize

        public override void Initialize()
        {
            Settings.VelocityIterations = 2;
            Settings.PositionIterations = 4;

            GameInstance.ViewCenter = Vector2.Zero;

            _worldSize = 2 * GameInstance.ConvertScreenToWorld(GameInstance.Window.ClientBounds.Width, 0);

            //Create a World using QuadTree constructor
            World = new World(new Vector2(0.0f, -10.0f), new AABB(-_worldSize / 2, _worldSize / 2));

            //Create a World using DynamicTree constructor
            //World = new World(new Vector2(0.0f, -10.0f));

            //
            //set up border
            //

            float halfWidth = _worldSize.X / 2 - 2f;
            float halfHeight = _worldSize.Y / 2 - 2f;

            Vertices borders = new Vertices(4);
            borders.Add(new Vector2(-halfWidth, halfHeight));
            borders.Add(new Vector2(halfWidth, halfHeight));
            borders.Add(new Vector2(halfWidth, -halfHeight));
            borders.Add(new Vector2(-halfWidth, -halfHeight));

            Body anchor = BodyFactory.CreateLoopShape(World, borders);
            anchor.CollisionCategories = Category.All;
            anchor.CollidesWith = Category.All;

            //
            //box
            //

            Vertices bigbox = PolygonTools.CreateRectangle(3f, 3f);
            PolygonShape bigshape = new PolygonShape(bigbox, 5);

            Body bigbody = BodyFactory.CreateBody(World);
            bigbody.BodyType = BodyType.Dynamic;
            bigbody.Position = Vector2.UnitX * 25;
            bigbody.CreateFixture(bigshape);

            World.RemoveBody(bigbody);

            //
            //populate
            //
            //const int rad = 12;
            //const float a = 0.6f;
            //const float sep = 0.000f;

            //Vector2 cent = Vector2.Zero;

            //for (int y = -rad; y <= +rad; y++)
            //{
            //    int xrad = (int)Math.Round(Math.Sqrt(rad * rad - y * y));
            //    for (int x = -xrad; x <= +xrad; x++)
            //    {
            //        Vector2 pos = cent + new Vector2(x * (2 * a + sep), y * (2 * a + sep));
            //        Body cBody = BodyFactory.CreateCircle(World, a, 55, pos);
            //        cBody.BodyType = BodyType.Dynamic;
            //    }
            //}

            base.Initialize();
        }
开发者ID:boris2,项目名称:mmogameproject2,代码行数:68,代码来源:QuadTreeTest.cs

示例12: CreatePowerUpShot

        public void CreatePowerUpShot(Sprite _shot, Vector2 firingLocation, World physicsWorld, Vector2 linearVelocity)
        {
            appleCopterTimer = 0;
            isAppleCopter = false;
            _shot.spriteBody.IsSensor = false; //makes physical body live to damage leaving barrel

            switch (ActivePowerUpBarrel.TextureIndex)
            {
                //relay barrel
                case 0:
                    {
                        _shot.TotalRotation = ActivePowerUpBarrel.TotalRotation;
                        _shot.Location = new Vector2((int)firingLocation.X - _shot.SpriteRectWidth / 2, (int)firingLocation.Y - _shot.SpriteRectHeight / 2);
                        _shot.spriteBody.Position = ConvertUnits.ToSimUnits(_shot.SpriteCenterInWorld);
                        _shot.spriteBody.Rotation = _shot.TotalRotation;
                        _shot.spriteBody.IgnoreGravity = false;
                        _shot.IsVisible = true;
                        break;
                    }
                //fire barrel
                case 1:
                    {
                        _shot.TextureID = 10;
                        _shot.TextureIndex = 0;
                        _shot.SpriteType = Sprite.Type.FireballShot;
                        _shot.SpriteRectangle = new Rectangle((int)firingLocation.X - 126, (int)firingLocation.Y - 126, 252, 252);
                        _shot.IsEffect = true;
                        _shot.TotalRotation = ActivePowerUpBarrel.TotalRotation + MathHelper.ToRadians(-90);
                        _shot.IsExpired = false;
                        _shot.IsCollidable = true;
                        _shot.HitPoints = 1;
                        _shot.IsAwake = true;
                        _shot.IsVisible = true;
                        _shot.IsHit = false;
                        _shot.TintColor = new Color(255f, 255f, 255f, 255f);
                        _shot.Scale = 1.0f;
                        _shot.IsAnimated = false;
                        _shot.AnimationFPS = fireicelitanimationspeed;
                        _shot.AnimationFramePrecise = 0.0f;
                        _shot.CurrentFrame = 0;
                        _shot.pathing = Sprite.Pathing.None;
                        _shot.InitPathingPoint();
                        _shot.pathingTravelled = 0.001f;

                        physicsWorld.RemoveBody(_shot.spriteBody);
                        Vector2 position = ConvertUnits.ToSimUnits(_shot.SpriteCenterInWorld);
                        _shot.spriteBody = BodyFactory.CreateEllipse(physicsWorld, ConvertUnits.ToSimUnits(32f), ConvertUnits.ToSimUnits(32f), 8, 1.0f, position, _shot);

                        _shot.spriteBody.ResetDynamics();
                        _shot.spriteBody.Mass = 0.15f;
                        _shot.spriteBody.Rotation = _shot.TotalRotation;
                        _shot.spriteBody.BodyType = BodyType.Dynamic;
                        _shot.spriteBody.IgnoreGravity = true;
                        _shot.spriteBody.IsBullet = true;
                        _shot.spriteBody.IsSensor = true;
                        _shot.spriteBody.Restitution = 0.5f;
                        _shot.spriteBody.Friction = 0.5f;

                        //poof barrel if its not the starting barrel
                        if (ActivePowerUpBarrel.HitPoints >= 0 && ActivePowerUpBarrel != ShotStartBarrel) ActivePowerUpBarrel.IsHit = true;

                        break;
                    }
                //ice barrel
                case 2:
                    {
                        _shot.TextureID = 5;
                        _shot.TextureIndex = 0;
                        _shot.SpriteType = Sprite.Type.IceShot;
                        _shot.SpriteRectangle = new Rectangle((int)firingLocation.X - 126, (int)firingLocation.Y - 126, 252, 252);
                        _shot.IsEffect = true;
                        _shot.TotalRotation = ActivePowerUpBarrel.TotalRotation + MathHelper.ToRadians(-90);
                        _shot.IsExpired = false;
                        _shot.IsCollidable = true;
                        _shot.HitPoints = 1;
                        _shot.IsAwake = true;
                        _shot.IsVisible = true;
                        _shot.IsHit = false;
                        _shot.TintColor = new Color(255f, 255f, 255f, 255f);
                        _shot.Scale = 1.0f;
                        _shot.IsAnimated = true;
                        _shot.IsAnimatedWhileStopped = true;
                        _shot.IsBounceAnimated = false;
                        _shot.IsAnimationDirectionForward = true;
                        _shot.AnimationFPS = fireicelitanimationspeed;
                        _shot.AnimationFramePrecise = 0.0f;
                        _shot.CurrentFrame = 0;
                        _shot.pathing = Sprite.Pathing.None;
                        _shot.InitPathingPoint();
                        _shot.pathingTravelled = 0.001f;

                        physicsWorld.RemoveBody(_shot.spriteBody);
                        Vector2 position = ConvertUnits.ToSimUnits(_shot.SpriteCenterInWorld);
                        _shot.spriteBody = BodyFactory.CreateEllipse(physicsWorld, ConvertUnits.ToSimUnits(32f), ConvertUnits.ToSimUnits(32f), 8, 1.0f, position, _shot);

                        _shot.spriteBody.ResetDynamics();
                        _shot.spriteBody.Mass = 0.15f;
                        _shot.spriteBody.Rotation = _shot.TotalRotation;
                        _shot.spriteBody.BodyType = BodyType.Dynamic;
                        _shot.spriteBody.IgnoreGravity = true;
//.........这里部分代码省略.........
开发者ID:markadamdixon,项目名称:CompletedGame_ProduceWars_CSharp,代码行数:101,代码来源:ShotManager.cs

示例13: CreateFruitShot

        public void CreateFruitShot(Vector2 firingLocation, World physicsWorld)
        {
            appleCopterTimer = 0;
            isAppleCopter = false;
            shot.TextureID = 20;
            shot.TextureIndex = 0;
            shot.CurrentFrame = 0;
            shot.IsEffect = false;
            shot.SpriteType = Sprite.Type.FruitShot;
            if (selectedAmmo == 0) shot.TextureIndex = LevelDataManager.rand.Next(0, 3) * 7; //gets random color of apple (sets 0,7,14 texture index on fruit sheet) if its an apple
            if (selectedAmmo == 1) shot.TextureIndex = 21;
            if (selectedAmmo == 2) shot.TextureIndex = 28;
            if (selectedAmmo == 3) shot.TextureIndex = 35;
            if (selectedAmmo == 4) shot.TextureIndex = 42;
            if (selectedAmmo == 5) shot.TextureIndex = 49;
            if (selectedAmmo == 6) shot.TextureIndex = 56;

            shot.TotalRotation = 0;
            shot.SpriteRectangle = new Rectangle ((int)firingLocation.X - 32, (int)firingLocation.Y -32, 64, 64);
            shot.IsExpired = false;
            shot.IsCollidable = true;
            shot.IsAwake = true;
            shot.IsVisible = true;
            shot.IsHit = false;
            shot.TintColor = new Color(255f,255f,255f,255f);
            shot.Scale = 1.0f;
            shot.IsAnimated = false;
            shot.AnimationFPS = animationSpeed;
            shot.CurrentFrame = LevelDataManager.rand.Next(0, 3);
            shot.pathing = Sprite.Pathing.None;
            shot.InitPathingPoint();
            shot.pathingTravelled = 0f;

            //create new body
            physicsWorld.RemoveBody(shot.spriteBody);
            Vector2 position = ConvertUnits.ToSimUnits(shot.Location + shot.SpriteOrigin);
            int spriteRow = shot.TextureIndex / LevelDataManager.SpritesInRow(shot);
            switch (spriteRow)
            {
                case 0:
                case 1:
                case 2:
                    {
                        //apple
                        Vertices vertices = new Vertices(9);
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(14f, 29f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(-12f, 29f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(-24f, 16f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(-30f, -4f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(-30f, -8f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(-18f, -18f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(18f, -18f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(26f, -10f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(26f, 12f)));
                        shot.spriteBody = BodyFactory.CreatePolygon(physicsWorld, vertices, 1.0f, position, shot);
                        break;
                    }
                case 3:
                    {
                        //orange
                        shot.spriteBody = BodyFactory.CreateEllipse(physicsWorld, ConvertUnits.ToSimUnits(30f), ConvertUnits.ToSimUnits(30f), 10, 1.0f, position, shot);
                        break;
                    }
                case 4:
                    {
                        //strawberry
                        Vertices vertices = new Vertices(8);
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(8f, 30f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(-8f, 30f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(-24f, 6f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(-24f, -8f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(-10f, -17f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(10f, -17f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(24f, -8f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(24f, 10f)));
                        shot.spriteBody = BodyFactory.CreatePolygon(physicsWorld, vertices, 1.0f, position, shot);
                        break;
                    }
                case 5:
                    {
                        //cherry
                        Vertices vertices = new Vertices(8);
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(26f, 20f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(2f, 29f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(-11f, 29f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(-30f, 7f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(-30f, -2f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(-21f, -11f)));
                        //vertices.Add(ConvertUnits.ToSimUnits(new Vector2(0f, 0f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(23f, -1f)));
                        vertices.Add(ConvertUnits.ToSimUnits(new Vector2(28f, 7f)));
                        shot.spriteBody = BodyFactory.CreatePolygon(physicsWorld, vertices, 1.0f, position, shot);
                        splitShot[0].IsExpired = false;
                        splitShot[1].IsExpired = false;
                        splitShot[2].IsExpired = false;
                        break;
                    }
                case 6:
                    {
                        //banana
//.........这里部分代码省略.........
开发者ID:markadamdixon,项目名称:CompletedGame_ProduceWars_CSharp,代码行数:101,代码来源:ShotManager.cs

示例14: RemovePhysics

 /// <summary>
 /// Remove from physical World
 /// </summary>
 /// <param name="PhysicalWorld"></param>
 public void RemovePhysics(World PhysicalWorld)
 {
     if (Fixture != null)
     {
         PhysicalWorld.RemoveBody(Fixture.Body);
         _Fixture = null;
     }
 }
开发者ID:BartoszF,项目名称:ArtifactsRider,代码行数:12,代码来源:Tile.cs

示例15: RemoveBodies

 public override void RemoveBodies(World world)
 {
     world.RemoveBody(_body);
 }
开发者ID:HaKDMoDz,项目名称:Zazumo,代码行数:4,代码来源:PlaceablePhysics.cs


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