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


C# Dynamics.World类代码示例

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


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

示例1: AttachBodiesWithRevoluteJoint

        /// <summary>
        /// Attaches the bodies with revolute joints.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="bodies">The bodies.</param>
        /// <param name="localAnchorA">The local anchor A.</param>
        /// <param name="localAnchorB">The local anchor B.</param>
        /// <param name="connectFirstAndLast">if set to <c>true</c> [connect first and last].</param>
        /// <param name="collideConnected">if set to <c>true</c> [collide connected].</param>
        public static List<RevoluteJoint> AttachBodiesWithRevoluteJoint(World world, List<Body> bodies,
            Vector2 localAnchorA,
            Vector2 localAnchorB, bool connectFirstAndLast,
            bool collideConnected)
        {
            List<RevoluteJoint> joints = new List<RevoluteJoint>(bodies.Count + 1);

            for (int i = 1; i < bodies.Count; i++)
            {
                RevoluteJoint joint = new RevoluteJoint(bodies[i], bodies[i - 1], localAnchorA, localAnchorB);
                joint.CollideConnected = collideConnected;
                world.AddJoint(joint);
                joints.Add(joint);
            }

            if (connectFirstAndLast)
            {
                RevoluteJoint lastjoint = new RevoluteJoint(bodies[0], bodies[bodies.Count - 1], localAnchorA,
                                                            localAnchorB);
                lastjoint.CollideConnected = collideConnected;
                world.AddJoint(lastjoint);
                joints.Add(lastjoint);
            }

            return joints;
        }
开发者ID:seankruer,项目名称:eecs-290-super-power-robots,代码行数:35,代码来源:PathManager.cs

示例2: CreateFixedAngleJoint

        /// <summary>
        /// Creates a fixed angle joint.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="body">The body.</param>
        /// <returns></returns>
        public static FixedAngleJoint CreateFixedAngleJoint(World world, Body body)
        {
            FixedAngleJoint angleJoint = new FixedAngleJoint(body);
            world.AddJoint(angleJoint);

            return angleJoint;
        }
开发者ID:scastle,项目名称:Solitude,代码行数:13,代码来源:JointFactory.cs

示例3: CreateFixedDistanceJoint

 public static FixedDistanceJoint CreateFixedDistanceJoint(World world, Body body, Vector2 localAnchor,
                                                           Vector2 worldAnchor)
 {
     FixedDistanceJoint distanceJoint = new FixedDistanceJoint(body, localAnchor, worldAnchor);
     world.AddJoint(distanceJoint);
     return distanceJoint;
 }
开发者ID:scastle,项目名称:Solitude,代码行数:7,代码来源:JointFactory.cs

示例4: CreateAngleJoint

        /// <summary>
        /// Creates an angle joint.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="bodyA">The first body.</param>
        /// <param name="bodyB">The second body.</param>
        /// <returns></returns>
        public static AngleJoint CreateAngleJoint(World world, Body bodyA, Body bodyB)
        {
            AngleJoint angleJoint = new AngleJoint(bodyA, bodyB);
            world.AddJoint(angleJoint);

            return angleJoint;
        }
开发者ID:scastle,项目名称:Solitude,代码行数:14,代码来源:JointFactory.cs

示例5: CreateDistanceJoint

 public static DistanceJoint CreateDistanceJoint(World world, Body bodyA, Body bodyB, Vector2 anchorA,
                                                 Vector2 anchorB)
 {
     DistanceJoint distanceJoint = new DistanceJoint(bodyA, bodyB, anchorA, anchorB);
     world.AddJoint(distanceJoint);
     return distanceJoint;
 }
开发者ID:scastle,项目名称:Solitude,代码行数:7,代码来源:JointFactory.cs

示例6: MasslessItem

        public MasslessItem(Texture2D t, PhysicsShape shape, Vector2 position, World w)
            : base(position, w, t.Width, t.Height)
        {
            texture = t;
            body.BodyType = BodyType.Static;
            body.Position = position;

            switch (shape)
            {
                case PhysicsShape.Rectangle:
                    fixture = FixtureFactory.CreateRectangle(
                        texture.Width,
                        texture.Height,
                        0.0f,
                        Vector2.Zero,
                        body);
                    break;
            }

            //fixture.CollisionFilter.IgnoreCollisionWith();

            fixture.OnCollision += new OnCollisionEventHandler(this.OnCollision);
            w.AddBody(body);

            //drawOrigin = new Vector2(texture.Width / 2, texture.Height / 2);
            //drawRectangle = new Rectangle(0, 0, texture.Width, texture.Height);
        }
开发者ID:scastle,项目名称:Solitude,代码行数:27,代码来源:MasslessItem.cs

示例7: Battle

        public Battle(SPRWorld sprWorld, int botHalfWidth, World world, int currentLevel)
        {
            this.sprWorld = sprWorld;
            this.botHalfWidth = botHalfWidth;
            this.world = world;

            xmlDoc = new XmlDocument();

            if (nextAllies == "")
            {
                xmlDoc.Load("Games/SuperPowerRobots/Storage/Allies.xml");
            }
            else
            {
                xmlDoc.LoadXml(nextAllies);
            }

            //xmlDoc.

            XmlNodeList nodes = xmlDoc.GetElementsByTagName("Bot");

            Vector2[] edges = { new Vector2(-botHalfWidth, -botHalfWidth) * Settings.MetersPerPixel, new Vector2(botHalfWidth, -botHalfWidth) * Settings.MetersPerPixel, new Vector2(botHalfWidth, botHalfWidth) * Settings.MetersPerPixel, new Vector2(-botHalfWidth, botHalfWidth) * Settings.MetersPerPixel };

            CreateBots(nodes, edges);

            xmlDoc.Load("Games/SuperPowerRobots/Storage/Battles.xml");

            nodes = xmlDoc.GetElementsByTagName("Level");

            nodes = nodes[currentLevel].ChildNodes;

            CreateBots(nodes, edges);
        }
开发者ID:oab7,项目名称:eecs-290-super-power-robots,代码行数:33,代码来源:Battle.cs

示例8: CreateBreakableBody

        /// <summary>
        /// Creates a breakable body. You would want to remove collinear points before using this.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="vertices">The vertices.</param>
        /// <param name="density">The density.</param>
        /// <param name="position">The position.</param>
        /// <returns></returns>
        public static BreakableBody CreateBreakableBody(World world, Vertices vertices, float density, Vector2 position,
                                                        Object userData)
        {
            List<Vertices> triangles = EarclipDecomposer.ConvexPartition(vertices);

            BreakableBody breakableBody = new BreakableBody(triangles, world, density, userData);
            breakableBody.MainBody.Position = position;
            world.AddBreakableBody(breakableBody);

            return breakableBody;
        }
开发者ID:scastle,项目名称:Solitude,代码行数:19,代码来源:FixtureFactory.cs

示例9: Bomb

        public Bomb(Vector2 position, World world, Vector2 velocity)
            : base(position, world, TextureStatic.Get("bomb").Width, TextureStatic.Get("bomb").Height)
        {
            body.BodyType = BodyType.Dynamic;
            texture = TextureStatic.Get("bomb");
            fixture = FixtureFactory.CreateCircle(TextureStatic.Get("bomb").Width / 2, 1, body);

            laidTime = GameClock.Now;
            world.AddBody(body);
            body.LinearVelocity = velocity;
        }
开发者ID:scastle,项目名称:Solitude,代码行数:11,代码来源:Bomb.cs

示例10: Explosion

 public Explosion(Vector2 position, World world, float radius, int power)
     : base(position, world, TextureStatic.Get("solitudeExplosion").Width, TextureStatic.Get("solitudeExplosion").Height)
 {
     body.BodyType = BodyType.Kinematic;
     body.Position = position;
     this.radius = 1f;
     maxRadius = radius;
     this.power = power;
     fixture = FixtureFactory.CreateCircle(this.maxRadius, 0f, body);
     fixture.CollisionFilter.CollidesWith = Category.None;
     texture = TextureStatic.Get("solitudeExplosion");
 }
开发者ID:scastle,项目名称:Solitude,代码行数:12,代码来源:Explosion.cs

示例11: SolitudeObject

        public SolitudeObject(Vector2 position, World world, Shape shape, float width, float height)
        {
            body = BodyFactory.CreateBody(world, position);

            //currently in wall class:
            fixture = new Fixture(body, shape);
            fixture.OnCollision += new OnCollisionEventHandler(OnCollision);
            //###################

            drawOrigin = new Vector2(width, height);
            drawRectangle = new Rectangle(0, 0, (int)width, (int)height);
        }
开发者ID:scastle,项目名称:Solitude,代码行数:12,代码来源:SolitudeObject.cs

示例12: Mauler

 public Mauler(Vector2 position, World w)
     : base(position, w, TextureStatic.Get("solitudeMauler").Width, TextureStatic.Get("solitudeMauler").Height)
 {
     health = Settings.maulerHealth;
     world = w;
     body.BodyType = BodyType.Dynamic;
     body.Position = position;
     texture = TextureStatic.Get("solitudeMauler");
     fixture = FixtureFactory.CreateCircle(texture.Width/2, 0.25f, body, Vector2.Zero);
     fixture.OnCollision += new OnCollisionEventHandler(OnCollision);
     world.AddBody(body);
     targetPoint = body.Position;
 }
开发者ID:scastle,项目名称:Solitude,代码行数:13,代码来源:Mauler.cs

示例13: BreakableBody

        public BreakableBody(IEnumerable<Vertices> vertices, World world, float density, Object userData)
        {
            _world = world;
            _world.ContactManager.PostSolve += PostSolve;
            MainBody = new Body(_world);
            MainBody.BodyType = BodyType.Dynamic;

            foreach (Vertices part in vertices)
            {
                PolygonShape polygonShape = new PolygonShape(part, density);
                Fixture fixture = MainBody.CreateFixture(polygonShape, userData);
                Parts.Add(fixture);
            }
        }
开发者ID:seankruer,项目名称:eecs-290-super-power-robots,代码行数:14,代码来源:BreakableBody.cs

示例14: Fighter

 public Fighter(Vector2 position, World w)
     : base(position, w, TextureStatic.Get("fighter").Width, TextureStatic.Get("fighter").Height)
 {
     this.health = Settings.fighterHealth;
     world = w;
     lastShot = GameClock.Now;
     world = w;
     body.BodyType = BodyType.Dynamic;
     body.Position = position;
     texture = TextureStatic.Get("fighter");
     fixture = FixtureFactory.CreateRectangle(texture.Width, texture.Height, 0.25f, Vector2.Zero, body);
     world.AddBody(body);
     targetPoint = body.Position;
 }
开发者ID:scastle,项目名称:Solitude,代码行数:14,代码来源:Fighter.cs

示例15: TyTaylor

        public TyTaylor(World w, Vector2 position)
            : base(position, w, TextureStatic.Get("ty").Width, TextureStatic.Get("ty").Height)
        {
            health = Settings.TyHealth;
            world = w;
            lastShot = GameClock.Now;
            body.BodyType = BodyType.Dynamic;
            body.Position = position;
            texture = TextureStatic.Get("ty");
            fixture = FixtureFactory.CreateRectangle(texture.Width, texture.Height, 0.25f, Vector2.Zero, body);
            world.AddBody(body);
            targetPoint = body.Position;

            fixture.OnCollision += new OnCollisionEventHandler(this.OnCollision);
        }
开发者ID:scastle,项目名称:Solitude,代码行数:15,代码来源:TyTaylor.cs


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