Beispiel #1
0
        public void LevelReading()
        {
            if (levelNumber < 4)
            {
                XmlReader reader = XmlReader.Create("Resources/Level" + Convert.ToString(levelNumber) + ".xml", null);

                reader.ReadToFollowing("x");
                int rollStartX = Convert.ToInt32(reader.ReadString());
                reader.ReadToFollowing("y");
                int rollStartY = Convert.ToInt32(reader.ReadString());

                roll = new Roll(rollStartX, rollStartY, rollSize, "None");

                reader.ReadToFollowing("x");
                int doodooStartX = Convert.ToInt32(reader.ReadString());
                reader.ReadToFollowing("y");
                int doodooStartY = Convert.ToInt32(reader.ReadString());

                doodoo = new DooDoo(doodooStartX, doodooStartY, doodooSize, "None");

                reader.ReadToFollowing("x");
                int grateX = Convert.ToInt32(reader.ReadString());
                reader.ReadToFollowing("y");
                int grateY = Convert.ToInt32(reader.ReadString());
                reader.ReadToFollowing("Size");
                int grateSize = Convert.ToInt32(reader.ReadString());

                grate = new Grate(grateX, grateY, grateSize);

                reader.ReadToFollowing("x");
                int grateX2 = Convert.ToInt32(reader.ReadString());
                reader.ReadToFollowing("y");
                int grateY2 = Convert.ToInt32(reader.ReadString());
                reader.ReadToFollowing("Size");
                int grateSize2 = Convert.ToInt32(reader.ReadString());

                grate2 = new Grate(grateX2, grateY2, grateSize2);

                reader.ReadToFollowing("x");
                redpowerupX = Convert.ToInt32(reader.ReadString());
                reader.ReadToFollowing("y");
                redpowerupY = Convert.ToInt32(reader.ReadString());
                reader.ReadToFollowing("Size");
                powerupSize = Convert.ToInt32(reader.ReadString());

                reader.ReadToFollowing("x");
                bluepowerupX = Convert.ToInt32(reader.ReadString());
                reader.ReadToFollowing("y");
                bluepowerupY = Convert.ToInt32(reader.ReadString());


                reader.ReadToFollowing("walls");

                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Text)
                    {
                        int x = Convert.ToInt16(reader.ReadString());

                        reader.ReadToFollowing("y");
                        int y = Convert.ToInt16(reader.ReadString());

                        reader.ReadToFollowing("Width");
                        int Width = Convert.ToInt16(reader.ReadString());

                        reader.ReadToFollowing("Height");
                        int Height = Convert.ToInt16(reader.ReadString());

                        Wall w = new Wall(x, y, Width, Height);

                        wallList.Add(w);
                    }
                }
                reader.Close();
            }
        }