public static List<Enemy> loadEnemyInfo(ContentManager Content) { List<Enemy> list = new List<Enemy>(); XmlDocument doc = new XmlDocument(); doc.Load(@"Data/enemy.dat"); XmlNodeList enemies = doc.SelectNodes("//enemy"); for (int i = 0; i < enemies.Count; i++) { Texture2D texture = Content.Load<Texture2D>(enemies[i].InnerText); string kind = enemies[i].Attributes["kind"].Value; SoundEffect sound = null; switch (kind) { case "bear": sound = SoundManager.so_bearSound; break; case "cat": sound = SoundManager.so_catSound; break; case "dragon": sound = SoundManager.so_dragonSound; break; case "fox": sound = SoundManager.so_foxSound; break; case "lion": sound = SoundManager.so_lionSound; break; case "wolf": sound = SoundManager.so_wolfSound; break; } Animal animal = new Animal(texture, Vector2.Zero, kind, sound, int.Parse(enemies[i].Attributes["lvlreq"].Value), int.Parse(enemies[i].Attributes["health"].Value), int.Parse(enemies[i].Attributes["coin"].Value), int.Parse(enemies[i].Attributes["damage"].Value), float.Parse(enemies[i].Attributes["speed"].Value), float.Parse(enemies[i].Attributes["framepersec"].Value), int.Parse(enemies[i].Attributes["rows"].Value), int.Parse(enemies[i].Attributes["cols"].Value), Content.Load<Texture2D>(@"Sprite\Image\Enemy\health_bar")); list.Add(animal); } return list; }
public override Enemy Clone() { Enemy animal = new Animal(this.Sprite.Texture, Vector2.Zero, this.Kind, this.Sound, this.LevelReq, this.StartHealth, this.Coin, this.Damage, this.Speed, this.FramePerSec, this.Sprite.nRow, this.Sprite.nCol, this.HealthBar); return animal; }