當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。