Esempio n. 1
0
        public FixtureNode(FixtureDefSerialized fixture)
            : base(fixture.Name)
        {
            Name = fixture.Name;
            Fixture = fixture.Fixture;

            SetShape(new ShapeNode(new CircleShape(0.5f)));
        }
Esempio n. 2
0
        private void newFixtureToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var fixture = new FixtureDefSerialized(new FixtureDef(null, 0.2f), -1, "Fixture");
            var node = new FixtureNode(fixture);

            var selectedNode = treeView1.SelectedNode;

            if (selectedNode is BodyNode || selectedNode is WorldNode)
            {
                selectedNode.Nodes.Add(node);
                selectedNode.Expand();
            }
            else
                treeView1.Nodes[0].Nodes.Add(node);

            WorldObject.Fixtures.Add(node);
        }
Esempio n. 3
0
        public void SerializeFixture(FixtureDefSerialized fixture)
        {
            writer.WriteStartElement("Fixture");

            writer.WriteElementString("Shape", fixture.ShapeID.ToString());

            #if !SKIP_DEFAULT_CHECKS
            if (!string.IsNullOrEmpty(fixture.Name))
            #endif
                writer.WriteElementString("Name", fixture.Name);

            #if !SKIP_DEFAULT_CHECKS
            if (fixture.Fixture.Density != defaultFixtureDefData.Density)
            #endif
                writer.WriteElementString("Density", fixture.Fixture.Density.ToString());

            #if !SKIP_DEFAULT_CHECKS
            if (fixture.Fixture.Filter != defaultFixtureDefData.Filter)
            #endif
                WriteSimpleType(typeof(FilterData), fixture.Fixture.Filter);

            #if !SKIP_DEFAULT_CHECKS
            if (fixture.Fixture.Friction != defaultFixtureDefData.Friction)
            #endif
                writer.WriteElementString("Friction", fixture.Fixture.Friction.ToString());

            #if !SKIP_DEFAULT_CHECKS
            if (fixture.Fixture.IsSensor != defaultFixtureDefData.IsSensor)
            #endif
                writer.WriteElementString("IsSensor", fixture.Fixture.IsSensor.ToString());

            #if !SKIP_DEFAULT_CHECKS
            if (fixture.Fixture.Restitution != defaultFixtureDefData.Restitution)
            #endif
                writer.WriteElementString("Restitution", fixture.Fixture.Restitution.ToString());

            if (fixture.Fixture.UserData != null)
            {
                writer.WriteStartElement("UserData");
                WriteDynamicType(fixture.Fixture.UserData.GetType(), fixture.Fixture.UserData);
                WriteEndElement();
            }

            WriteEndElement();
        }