Ejemplo n.º 1
0
        private static void KillMouseJoints(World w, KinectRagdollGame g)
        {
            List<FixedMouseJoint> mjs = new List<FixedMouseJoint>();

            foreach (Joint j in w.JointList)
            {
                if (j is FixedMouseJoint) w.RemoveJoint(j);
            }

            w.ProcessChanges();
        }
Ejemplo n.º 2
0
        public void RemoveRope(Rope rope)
        {
            foreach (var joint in rope.PhysicsSegmentJoints)
            {
                PhysicsWorld.RemoveJoint(joint);
            }

            rope.PhysicsSegmentJoints.Clear();

            foreach (var body in rope.PhysicsSegments)
            {
                RopesByPhysicsBody.Remove(body);
                RemoveBody(body);
            }

            rope.PhysicsSegments.Clear();
            if (rope.AttachedEntity is Ball)
            {
                (rope.AttachedEntity as Ball).PhysicsBody.Mass          = 10f;
                (rope.AttachedEntity as Ball).PhysicsBody.FixedRotation = true;
            }
        }
Ejemplo n.º 3
0
 public void Update(GameTime gameTime, CameraOperator cameraOperator, World world)
 {
     _sprite.Body.Center = Input.Mouse.Position;
     if (_mouseJoint != null)
     {
         if (Input.Mouse.IsButtonDown(Input.Mouse.MouseButton.Left))
         {
             _mouseJoint.WorldAnchorB = cameraOperator.Camera.PositionOnWorld(Input.Mouse.Position);
         }
         else
         {
             world.RemoveJoint(_mouseJoint);
             _mouseJoint = null;
         }
     }
     else
     {
         Vector2 cursorWorldPosition = cameraOperator.Camera.PositionOnWorld(Input.Mouse.Position);
         if (Input.Mouse.IsButtonClicked(Input.Mouse.MouseButton.Left))
         {
             Fixture fixture;
             float radiusMeters = _sprite.Body.Projection.BoundingBox.Dimensions.X.ToMeters();
             if ((fixture =
                 world.TestPoint(cursorWorldPosition - new Vector2(radiusMeters))) != null ||
                 (fixture =
                     world.TestPoint(cursorWorldPosition + new Vector2(radiusMeters))) != null ||
                 (fixture =
                     world.TestPoint(cursorWorldPosition + new Vector2(radiusMeters, -radiusMeters))) != null ||
                 (fixture =
                     world.TestPoint(cursorWorldPosition - new Vector2(radiusMeters, -radiusMeters))) != null)
             {
                 if (fixture.UserData is Coin)
                 {
                     _mouseJoint = new FixedMouseJoint(fixture.Body, cursorWorldPosition)
                     {
                         MaxForce = 200*fixture.Body.Mass
                     };
                     world.AddJoint(_mouseJoint);
                 }
             }
         }
     }
 }
Ejemplo n.º 4
0
 public void DisposePhysics(World world)
 {
     world.RemoveJoint(m_Joint);
 }