/// <summary> /// Create a new random enemy with properties based on current level /// </summary> public void CreateEnemy() { EnemyTemplate nextEnemy = enemies[RandomGen.SelectOne(enemies.Keys.ToArray())]; Enemy enemy = new Enemy(nextEnemy, GameManager.Level, route); enemy.Position = route.Values[0]; Add(enemy); enemy.Destroyed += delegate { Kill(enemy); }; GameManager.EnemiesAlive++; }
public Enemy(EnemyTemplate enemyTemplate, int level, SortedList <char, Vector> route) : base(15, 15) { int health = enemyTemplate.BaseHealth * level; Health = new IntMeter(health, 0, health); Health.LowerLimit += Destroy; Image = GameManager.Images[enemyTemplate.Image]; Value = enemyTemplate.Value; Tag = "Enemy"; CanRotate = false; IgnoresCollisionResponse = true; PathFollowerBrain brain = new PathFollowerBrain(new List <Vector>(route.Values)); brain.Speed = enemyTemplate.Speed; Brain = brain; ProgressBar HealthBar = new ProgressBar(Width, 3, Health); HealthBar.BarColor = Color.DarkGreen; HealthBar.Color = Color.BloodRed; HealthBar.Bottom = Bottom - 5; Add(HealthBar); AddCollisionHandler <Ammo>("Ammo", AmmoHit); AddCollisionHandler <Target>("Target", delegate { Explosion explosion = new Explosion(50); explosion.Position = Position; //Add(explosion); // TODO: Sound is way too loud :( GameManager.Target.Health.Value -= 100; Destroy(); }); }