Editor.Level.Read C# (CSharp) Méthode

Read() public méthode

public Read ( System element ) : void
element System
Résultat void
        public override void Read(System.Xml.XmlElement element)
        {
            this.Name = element.GetAttribute("name");
             this.NextLevel = element.GetAttribute("nextLevel");
             this.Background = element.GetAttribute("background");
             this.Foreground = element.GetAttribute("foreground");
             this.Foreground = element.GetAttribute("foreground");
             this.size = new Size(Int32.Parse(element.GetAttribute("width")), Int32.Parse(element.GetAttribute("height")));
        }

Usage Example

Exemple #1
0
        private void ReadLevel()
        {
            this.updating = true;

            var d = new OpenFileDialog();

            if (d.ShowDialog() == DialogResult.OK)
            {
                this.ClearLevel();


                var level = new Level();
                level.SetFileName(d.FileName);
                this.lstLevel.Items.Add(level);

                XmlDocument xml = new XmlDocument();
                xml.Load(d.FileName);
                level.Read(xml["level"]);
                foreach (XmlElement el in xml["level"]["actors"])
                {
                    Actor actor = new Actor();
                    actor.Read(el);
                }
                foreach (XmlElement el in xml["level"]["physics"])
                {
                    Physic p;
                    if (el.Name == "circle")
                    {
                        p = new Circle();
                    }
                    else if (el.Name == "polygon")
                    {
                        p = new Polygon();
                    }
                    else
                    {
                        MessageBox.Show(string.Format("unsupported physic '{0}'. Element skipped.", el.Name));
                        continue;
                    }
                    p.Read(el);
                }
            }

            this.updating = false;
            this.UpdateControls();
            this.GetCurrent().SelectedItem = this.GetCurrent().Items[0];
        }
All Usage Examples Of Editor.Level::Read