Beispiel #1
0
        private void Explode()
        {
            if (Alive)
            {
                Vector2 explosionPoint = body.Position;
                world.RemoveBody(body);
                world.ProcessChanges();
                body = null;

                CuttingTools.Cut(world, explosionPoint + new Vector2(2, 2), explosionPoint - new Vector2(2, 2), 0.01f);
                //world.ProcessChanges();
                CuttingTools.Cut(world, explosionPoint + new Vector2(-2, 2), explosionPoint - new Vector2(-2, 2), 0.01f);
                //world.ProcessChanges();

                Explosion e = new Explosion(world);
                e.Activate(explosionPoint, 2, 10);

                Alive = false;

                pivot = null;

                Vector2 screenLoc = ProjectionHelper.FarseerToPixel(explosionPoint);
                ParticleEffectManager.explosionEffect.Trigger(screenLoc);
            }
        }
Beispiel #2
0
 public override void Draw(SpriteBatch sb)
 {
     if (startBody != null)
     {
         SpriteHelper.DrawLine(sb, ProjectionHelper.FarseerToPixel(startBody.GetWorldPoint(startBodyLocal)), game.inputManager.inputHelper.MousePosition, 2f, Color.Blue);
     }
 }
        public override void Update()
        {
            ragdollPixel = ProjectionHelper.FarseerToPixel(game.ragdollManager.ragdoll.Body.Position);
            mePixel      = ProjectionHelper.FarseerToPixel(body.Position);

            base.Update();
        }
Beispiel #4
0
        private void Mouse()
        {
            InputHelper inputHelper = game.inputManager.inputHelper;

            Vector2 position = ProjectionHelper.PixelToFarseer(inputHelper.MousePosition);



            if (inputHelper.IsNewButtonPress(MouseButtons.RightButton))
            {
                Fixture f = game.farseerManager.world.TestPoint(position);
                FormManager.Property.setSelectedObject(f);
                if (f != null)
                {
                    FormManager.Property.setPendingObjects(new List <object> {
                        f.Body
                    });
                }
            }


            if (dragging && savedFixture != null)
            {
                Vector2 lastPosition;

                if (prevWorldLoc.X == 0 && prevWorldLoc.Y == 0)
                {
                    lastPosition = new Vector2(inputHelper.LastMouseState.X, inputHelper.LastMouseState.Y);
                }
                else
                {
                    lastPosition = ProjectionHelper.FarseerToPixel(prevWorldLoc);
                }

                prevWorldLoc = position;

                lastPosition = ProjectionHelper.PixelToFarseer(lastPosition);
                Vector2 dragVec = position - lastPosition;
                if (!FormManager.Property.tryGroupDrag(savedFixture, dragVec))
                {
                    savedFixture.Body.Position += position - lastPosition;
                }
            }

            if (inputHelper.IsOldButtonPress(MouseButtons.LeftButton))
            {
                MouseUp(position);
            }
            else if (inputHelper.IsNewButtonPress(MouseButtons.LeftButton))
            {
                MouseDown(position);
            }

            if (_fixedMouseJoint != null)
            {
                _fixedMouseJoint.WorldAnchorB = position;
            }
        }
Beispiel #5
0
        public void Draw()
        {
            Vector2 aim       = AimVector;
            Vector2 screenLoc = ProjectionHelper.FarseerToPixel(body.Position - aim * .5f);

            ParticleEffectManager.flameEffect[0].ReleaseImpulse     = aim * -60;
            ParticleEffectManager.flameEffect[0].ReleaseScale.Value = 40;
            ParticleEffectManager.flameEffect.Trigger(screenLoc);
        }
Beispiel #6
0
        public override void Draw(SpriteBatch sb)
        {
            //sb.Draw(dragTex, ProjectionHelper.FarseerToPixel(worldStart), null, Color.White, 0, new Vector2(dragTex.Width / 2, dragTex.Height / 2),

            if (drawing)
            {
                SpriteHelper.DrawCircle(sb, ProjectionHelper.FarseerToPixel(worldStart), GetPixelDragArea().diagonal * 2, new Color(100, 100, 255, 100));
            }

            //if (drawing)
            //    sb.Draw(dragTex, GetPixelDragArea().intRectangle, new Color(100, 100, 255, 100));
        }
Beispiel #7
0
        private void DrawSelectedJoints(SpriteBatch sb)
        {
            foreach (Joint j in selectedJoints)
            {
                Vector2 pixelLoc = ProjectionHelper.FarseerToPixel(j.WorldAnchorA);
                sb.Draw(pointTex, pixelLoc, null, Color.Red, 0, Vector2.One * pointTex.Width / 2, .2f, SpriteEffects.None, 0);
            }

            foreach (Joint j in pendingJoints)
            {
                Vector2 pixelLoc = ProjectionHelper.FarseerToPixel(j.WorldAnchorA);
                sb.Draw(pointTex, pixelLoc, null, Color.Yellow, 0, Vector2.One * pointTex.Width / 2, .2f, SpriteEffects.None, 0);
            }
        }
Beispiel #8
0
        public override void Draw(SpriteBatch sb)
        {
            if (polyPoints.First != null)
            {
                LinkedListNode <Vector2> a = polyPoints.First;
                LinkedListNode <Vector2> b = polyPoints.First.Next;

                while (b != null)
                {
                    SpriteHelper.DrawLine(sb, ProjectionHelper.FarseerToPixel(a.Value), ProjectionHelper.FarseerToPixel(b.Value), 2f, Color.Black);

                    a = b;
                    b = b.Next;
                }

                SpriteHelper.DrawLine(sb, ProjectionHelper.FarseerToPixel(a.Value), game.inputManager.inputHelper.MousePosition, 2f, Color.Blue);
            }
        }
Beispiel #9
0
 protected DragArea GetPixelDragArea()
 {
     return(new DragArea(ProjectionHelper.FarseerToPixel(worldStart), game.inputManager.inputHelper.MousePosition));
 }