Пример #1
0
        public static void Load(IEditor editor, string fileName)
        {
            editor.Clear();

            var doc = new XmlDocument();
            doc.Load(fileName);
            var waves = doc.SelectSingleNode("Waves");

            editor.WaveList = new ObservableCollection<Wave>();

            foreach (XmlNode wave in waves.SelectNodes("Wave"))
            {
                var w = new Wave();
                w.EnemyList = new ObservableCollection<Enemy>();

                foreach (XmlNode enemy in wave.SelectNodes("Enemy"))
                {
                    w.EnemyList.Add(new Enemy
                    {
                        Type = enemy.GetAttribute("Type"),
                        Spawn = float.Parse(enemy.GetAttribute("Spawn").Default("0")),
                        X = float.Parse(enemy.GetAttribute("X").Default("0")),
                        Speed = float.Parse(enemy.GetAttribute("Speed").Default("0")),
                        Money = float.Parse(enemy.GetAttribute("Money").Default("0"))
                    });
                }

                editor.WaveList.Add(w);
            }
        }
 private void AddButton_OnClick(object sender, RoutedEventArgs e)
 {
     var w = new Wave
     {
         EnemyList = new ObservableCollection<Enemy>()
     };
     WaveList.Add(w);
     WavesEdit.ItemsSource = WaveList;
 }