Пример #1
0
        protected override Fixture CreateFixture(DragArea d)
        {
            Fixture f = FixtureFactory.AttachRectangle(d.width, d.height, 1, Vector2.Zero, new Body(game.farseerManager.world));

            f.Body.Position = d.center;
            FarseerTextures.ApplyTexture(f, FarseerTextures.TextureType.Normal);
            return(f);
        }
Пример #2
0
        protected override Fixture CreateFixture(DragArea d)
        {
            Fixture f = FixtureFactory.AttachCircle(d.diagonal, 1, new Body(game.farseerManager.world));

            f.Body.Position = worldStart;
            FarseerTextures.ApplyTexture(f, FarseerTextures.TextureType.Normal);

            return(f);
        }
Пример #3
0
        public StopwatchObjective(KinectRagdollGame g, Body b)
            : base(g)
        {
            this.body = b;

            FarseerTextures.ApplyTexture(b, FarseerTextures.TextureType.Objective);

            Init(g);
        }
Пример #4
0
        internal void RemoveCollisionHandler()
        {
            foreach (Fixture f in Body.FixtureList)
            {
                f.BeforeCollision -= new BeforeCollisionEventHandler(f_BeforeCollision);
            }


            FarseerTextures.ApplyTexture(Body, FarseerTextures.TextureType.Normal);
        }
Пример #5
0
        public void addSpinningDeath()
        {
            Body    b   = new Body(world);
            Fixture rec = FixtureFactory.AttachRectangle(20, 2, 1, Vector2.Zero, b);

            b.Position = new Vector2(10, 0);

            rec.Body.BodyType = BodyType.Dynamic;
            FarseerTextures.ApplyTexture(rec, FarseerTextures.TextureType.Normal);

            FixedRevoluteJoint joint = new FixedRevoluteJoint(rec.Body, Vector2.Zero, new Vector2(20, 0));

            joint.MotorEnabled   = true;
            joint.MotorSpeed     = 6;
            joint.MaxMotorTorque = 10000;
            joint.MotorTorque    = 10000;
            world.AddJoint(joint);
        }
Пример #6
0
        private void MakePolygon()
        {
            Vector2 avgLoc = new Vector2();

            foreach (Vector2 vert in polyPoints)
            {
                avgLoc += vert;
            }
            avgLoc /= polyPoints.Count;



            Vertices verts = new Vertices();

            foreach (Vector2 v in polyPoints)
            {
                verts.Add(v - avgLoc);
            }

            Body           b           = new Body(game.farseerManager.world);
            List <Fixture> composition = FixtureFactory.AttachCompoundPolygon(EarclipDecomposer.ConvexPartition(verts), 1, b);

            b.Position = avgLoc;

            foreach (Fixture triangle in composition)
            {
                FarseerTextures.ApplyTexture(triangle, FarseerTextures.TextureType.Normal);
            }

            if (composition.Count > 0)
            {
                FormManager.Property.setPendingObjects(new List <object>()
                {
                    composition[0].Body
                });
            }

            polyPoints.Clear();
        }
Пример #7
0
        public override void HandleInput()
        {
            InputHelper input = game.inputManager.inputHelper;
            Vector2     pixel = input.MousePosition;

            worldLoc = ProjectionHelper.PixelToFarseer(pixel);

            if (input.IsNewButtonPress(MouseButtons.LeftButton) && !drawing)
            {
                drawing    = true;
                worldStart = worldLoc;
                //pixelStart = pixel;
                //d = new DragArea(worldStart, worldStart);
            }
            else if (input.IsOldButtonPress(MouseButtons.LeftButton) && drawing)
            {
                drawing = false;
                DragArea d = new DragArea(worldStart, worldLoc);
                if (d.width > 0 && d.height > 0)
                {
                    Fixture f = CreateFixture(d);

                    FormManager.Property.setPendingObjects(new List <object>()
                    {
                        f.Body
                    });
                    //FormManager.Property.setSelectedObject(f.Body);

                    f.Restitution = .3f;

                    if (input.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift))
                    {
                        f.Body.BodyType = BodyType.Dynamic;
                        FarseerTextures.ApplyTexture(f, FarseerTextures.TextureType.Normal);
                    }
                }
            }
        }
Пример #8
0
        public void addBounds()
        {
            int thickness = 5;


            Body b = new Body(world);

            FarseerTextures.ApplyTexture(
                FixtureFactory.AttachRectangle(70, thickness, 1, new Vector2(0, -25), b),
                FarseerTextures.TextureType.Normal);

            FarseerTextures.ApplyTexture(
                FixtureFactory.AttachRectangle(70, thickness, 1, new Vector2(0, 25), b),
                FarseerTextures.TextureType.Normal);

            FarseerTextures.ApplyTexture(
                FixtureFactory.AttachRectangle(thickness, 50, 1, new Vector2(35, 0), b),
                FarseerTextures.TextureType.Normal);

            FarseerTextures.ApplyTexture(
                FixtureFactory.AttachRectangle(thickness, 50, 1, new Vector2(-35, 0), b),
                FarseerTextures.TextureType.Normal);
        }
Пример #9
0
 protected override void ApplyTexture()
 {
     FarseerTextures.ApplyTexture(Body, FarseerTextures.TextureType.Powerup);
 }