Пример #1
0
        public KinectRagdollGame()
        {
            Main = this;

            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferWidth  = WIDTH;
            graphics.PreferredBackBufferHeight = HEIGHT;


            Content.RootDirectory = "Content";

            FarseerTextures.Init();
            FarseerTextures.SetGame(this);

            kinectManager  = new KinectManager();
            farseerManager = new FarseerManager(true, this);
            ragdollManager = new RagdollManager();

            actionCenter = new ActionCenter(this);
            inputManager = new InputManager(this);

            //spriteHelper = new SpriteHelper();
            objectiveManager      = new ObjectiveManager(this);
            powerupManager        = new PowerupManager(ragdollManager, farseerManager);
            jukebox               = new Jukebox();
            hazardManager         = new HazardManager(farseerManager, ragdollManager);
            particleEffectManager = new ParticleEffectManager(graphics, ref farseerProjection);

            toolbox = new Toolbox(this);


            this.IsMouseVisible = true;
            bkColor             = Color.CornflowerBlue;
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
0
        public StopwatchObjective(KinectRagdollGame g, Body b)
            : base(g)
        {
            this.body = b;

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

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


            FarseerTextures.ApplyTexture(Body, FarseerTextures.TextureType.Normal);
        }
Пример #6
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);
        }
Пример #7
0
        public override void HandleInput()
        {
            InputHelper input = game.inputManager.inputHelper;

            if (input.IsNewButtonPress(MouseButtons.LeftButton))
            {
                Vector2 position = ProjectionHelper.PixelToFarseer(input.MousePosition);

                List <Fixture> list = game.farseerManager.world.TestPointAll(position);

                if (list.Count > 0)
                {
                    Fixture            f = list[0];
                    StopwatchObjective o = new StopwatchObjective(game, f.Body);
                    game.objectiveManager.objectives.Add(o);
                }
            }
            else if (input.IsNewButtonPress(MouseButtons.RightButton))
            {
                Vector2 position = ProjectionHelper.PixelToFarseer(input.MousePosition);

                List <Fixture> list = game.farseerManager.world.TestPointAll(position);

                foreach (Fixture f in list)
                {
                    foreach (Objective o in game.objectiveManager.objectives)
                    {
                        if (o.GetType() == typeof(StopwatchObjective))
                        {
                            StopwatchObjective so = (StopwatchObjective)o;
                            if (so.body == f.Body)
                            {
                                game.objectiveManager.objectives.Remove(o);

                                FarseerTextures.RestoreTexture(f);
                                //if (so.oldMaterial != null)
                                //   f.UserData = so.oldMaterial;
                                break;
                            }
                        }
                    }
                }
            }
        }
Пример #8
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();
        }
Пример #9
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);
                    }
                }
            }
        }
Пример #10
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);
        }
Пример #11
0
 protected override void ApplyTexture()
 {
     FarseerTextures.ApplyTexture(Body, FarseerTextures.TextureType.Powerup);
 }