public void testTowerChangesTarget() { Tower t1 = new Tower("tower", 10, 1, 10, 100, new Rectangle(0, 0, 1, 11)); Enemy e1 = new Enemy(20, 1.0, "basic", 1, new Rectangle(30, 30, 1, 1)); Enemy e2 = new Enemy(20, 1.0, "basic", 1, new Rectangle(110, 110, 1, 1)); Map m = new Map("normal", 100, 2); m.PlaceTower(t1); m.SpawnEnemy(e1); m.SpawnEnemy(e2); m.Update();//adds all the approiate enemies to the towers lists t1.Update(); Assert.AreEqual(e1, t1.getCurrentTarget()); e2.moveTo(25,25); m.Update(); Assert.AreEqual(e2, t1.getCurrentTarget()); }
public void MoveBothEnemyOutofRange() { //testing that both enemies can move out of range after being attacked Enemy enemy2 = new Enemy(10, 1.0f, "basic", 10, new Rectangle(3, 3, 1, 1)); map.SpawnEnemy(enemy2); map.Update(); Assert.AreEqual(tower.Enemies.Count, 2); Assert.AreEqual(enemy.Health, 10); enemy.moveTo(5000, 5000); map.Update(); Assert.AreEqual(tower.Enemies.Count, 1); Assert.AreEqual(enemy2.Health, 10); enemy2.moveTo(6000, 6000); map.Update(); Assert.AreEqual(tower.Enemies.Count, 0); }