public void mapUpdatesDamageEnemiesWithTowers()
 {
     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);
 }
예제 #2
0
 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);
 }
        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());
        }