public GenerateData()
        {
            LevelData i = new LevelData();

            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;

            using (XmlWriter writer = XmlWriter.Create("Item.xml", settings))
            {
                IntermediateSerializer.Serialize(writer, i, "Item.xml");
            }
        }
        public LevelComponent(GameContent gameContent, World world)
        {
            this.gameContent = gameContent;
            this.world = world;

            levelData = gameContent.content.Load<LevelData>("Levels/level" + gameContent.levelIndex);

            MaxAtoms = levelData.MaxAtoms;

            int totalProbability = 0;
            for (int i = 0; i < levelData.AtomProbability.Length; i++) totalProbability += levelData.AtomProbability[i];

            if (totalProbability != 100) throw new Exception("must be 100");

            entryPoint = levelData.Entry;

            bonusType = levelData.BonusType;

            BodyDef bd = new BodyDef();
            Body ground = world.CreateBody(bd);

            PolygonShape ps = new PolygonShape();

            List<Vector2> v = levelData.ContinuousBoundry;
            for (int i = 0; i < v.Count - 1; i++)
            {
                if (v[i + 1].X == -1 && v[i + 1].Y == -1) { i++; continue; }

                ps.SetAsEdge(v[i] / gameContent.scale, v[i + 1] / gameContent.scale);
                ground.CreateFixture(ps, 0);
            }

            for (int i = 0; i < levelData.EquipmentDetails.Count; i++)
            {
                Equipment eq = new Equipment(levelData.EquipmentDetails[i].EquipmentName, gameContent, world);
                eq.body.Position = levelData.EquipmentDetails[i].Position / gameContent.scale;
                eq.body.Rotation = levelData.EquipmentDetails[i].RotationInDeg / 180 * (float)MathHelper.Pi;
                eq.isClamped = levelData.EquipmentDetails[i].IsClamped;
                eq.body.SetType(BodyType.Static);
                equipments.Add(eq);

                if (eq.equipName == EquipmentName.thermometer) thermometer = eq;

                if (eq.equipName == EquipmentName.pHscale) pHscale = eq;
            }
        }
        private void Load()
        {
            levelData = gameContent.content.Load<LevelData>("Levels/level" + levelIndex);

            soldiers.Add(new Soldier(Shape.Triangle, new Vector2(702, 185), gameContent, world));
            soldiers.Add(new Soldier(Shape.Triangle, new Vector2(752, 185), gameContent, world));
            soldiers.Add(new Soldier(Shape.Triangle, new Vector2(400, 160), gameContent, world));
            soldiers.Add(new Soldier(Shape.Triangle, new Vector2(440, 171), gameContent, world));
            soldiers.Add(new Soldier(Shape.Square, new Vector2(109, 316), gameContent, world));
            soldiers.Add(new Soldier(Shape.Square, new Vector2(346, 444), gameContent, world));

            PolygonShape pShape = new PolygonShape();

            BodyDef bd = new BodyDef();
            bd.type = BodyType.Static;

            for (int i = 0; i < levelData.Rectangles.Count; i++)
            {
                GroundData g = levelData.Rectangles[i];
                Rectangle r = new Rectangle(0, 0, g.Width, g.Height);
                pShape.SetAsBox((float)r.Width / 2 / gameContent.b2Scale, (float)r.Height / 2 / gameContent.b2Scale);

                bd.position = g.Position / gameContent.b2Scale;

                Body b = world.CreateBody(bd);
                b.CreateFixture(pShape, 1);
                b.Rotation = g.Rotation / 180 * (float)Math.PI;
            }
        }