public void SlowTowerTest() { Map map = new Map("normal", 100000, 2); Tower t = new Tower("slow", 10, 10, 10, 1, new Rectangle(70, 70, 1, 1)); Enemy e1 = new Enemy(100, 1, "basic", 100, new Rectangle(65, 65, 1, 1)); Enemy e2 = new Enemy(100, 1, "basic", 100, new Rectangle(75, 75, 1, 1)); map.PlaceTower(t); map.SpawnEnemy(e1); map.SpawnEnemy(e2); t.updateCounter = t.UpdateMax - 1; //e1.Counter = 1; //e2.Counter = 1; //map.Update(); t.Update(); Assert.AreEqual(new Rectangle(65, 65, 1, 1), e1.Location); Assert.AreEqual(new Rectangle(75, 75, 1, 1), e2.Location); map.Update(); Assert.AreEqual(new Rectangle(66, 66, 1, 1), e1.Location); Assert.AreEqual(new Rectangle(76, 76, 1, 1), e2.Location); Assert.AreEqual(t.Color, Color.Blue); }
public void testTwoTowerswithTwoEnemies() { Tower t1 = new Tower("basic", 10, 1, 10, 20, new Rectangle(10, 10, 1, 1)); Tower t2 = new Tower("basic", 10, 10, 10, 20, new Rectangle(20, 20, 1, 1)); Enemy e1 = new Enemy(20, 1.0, "basic", 1, new Rectangle(11, 11, 1, 1)); // In range of tower and tower 2, closer to tower 1 Enemy e2 = new Enemy(20, 1.0, "basic", 1, new Rectangle(19, 19, 1, 1)); // In range of tower and tower 2, closer to tower 2 Map m = new Map("normal", 100, 2); m.PlaceTower(t1); m.PlaceTower(t2); m.SpawnEnemy(e1); m.SpawnEnemy(e2); m.Update();//adds all the approiate enemies to the towers lists //Assert.IsNull(t1.getCurrentTarget()); t1.updateCounter = 59; t2.updateCounter = 59; t1.Update(); Assert.AreEqual(2, t1.Enemies.Count); Assert.AreEqual(2, t2.Enemies.Count); Assert.AreEqual(1, t1.AttackDamage); // e1.Health -= 19; t2.Update(); //Assert.AreEqual(19, e1.Health); Assert.AreEqual(e2.Health, 10); }
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 castleCanBeDestroyedStopsAll() { Map map = new Map("normal", 100000, 2); map.PlaceCastle(new Castle(1, new Rectangle(1, 1, 1, 1))); map.SpawnEnemy(new Enemy(1, 1, "basic", 1, new Rectangle(12, 12, 12, 12))); map.Castle.takeDamage(1); map.Update(); Assert.AreEqual(map.enemiesOnMap[0].Location, new Rectangle(12, 12, 12, 12)); }
public void castleCanBeDestroyed() { Map map = new Map("normal", 100000, 2); map.PlaceCastle(new Castle(1, new Rectangle(1, 1, 1, 1))); Assert.IsNotNull(map.Castle); map.Castle.takeDamage(1); map.Update(); Assert.IsNull(map.Castle); }
public void testTowerUpdatesEnemiesList() { Tower t1 = new Tower("tower", 10, 1, 10, 10, new Rectangle(0, 0, 10, 10)); Enemy e1 = new Enemy(20, 1.0, "basic", 1, new Rectangle(150, 150, 155, 155)); //Out of t1's range Map m = new Map("normal", 100, 2); m.PlaceTower(t1); m.SpawnEnemy(e1); m.Update();//adds all the approiate enemies to the towers lists t1.Update(); //Assert.AreEqual(e1, t1.getEnemyList.get(0)); Assert.AreEqual(0, t1.Enemies.Count); }
public void RedTowerTest() { Map map = new Map("normal", 100000, 2); Tower t = new Tower("dot", 10, 10, 10, 30, new Rectangle(70, 70, 1, 1)); Enemy e1 = new Enemy(30000, 1, "basic", 100, new Rectangle(65, 65, 1, 1)); map.PlaceTower(t); map.SpawnEnemy(e1); t.updateCounter = t.UpdateMax - 1; map.Update(); t.Update(); Assert.True(e1.BurnStop > e1.Counter); Assert.AreEqual(30000f, e1.Health); map.Update(); e1.Update(); Assert.AreEqual(29999f, e1.Health); for (int i = 0; i < 200; i++) e1.Update(); Assert.False(e1.BurnStop > e1.Counter); Assert.AreEqual(t.Color, Color.Red); }
public void NormalTowerTest() { Map map = new Map("normal", 100000, 2); Tower t = new Tower("basic", 10, 10, 10, 500, new Rectangle(70, 70, 1, 1)); Enemy special = new Enemy(20, 1.0f, "basic", 20, new Rectangle(1, 1, 1, 1)); map.SpawnEnemy(special); map.SellTower(t); map.PlaceTower(t); for (int i = 0; i <= 60; i++) { map.Update(); t.Update(); } Assert.AreEqual(special, t.getCurrentTarget());//Special should be the closest to the tower Assert.AreEqual(10, t.getCurrentTarget().Health); Assert.AreEqual(Color.White, t.Color); }