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 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 SetUp() { map = new Map("normal", 100000, 2); rec = new Rectangle(0, 0, 5, 5); tower = new Tower("basic", 10, 20, 30, 40, new Rectangle(5, 6, 1, 1)); enemy = new Enemy(10, 1.0f, "basic", 20, new Rectangle(rec.X + 5, rec.Y + 5, rec.Width, rec.Height)); }
public void SetUp() { map = new Map("normal", 0, 1); rec = new Rectangle(0, 0, 5, 5); tower = new Tower("", 10, 20, 30, 40, rec); enemy = new Enemy(10, 1.0f, "basic", 10, new Rectangle(30, 30, 50, 50)); }
public void TestThatScoreIncreasesBy125xGoldOnHard() { Map m = new Map("normal",100,3); m.SpawnEnemy(e); Assert.AreEqual(m.Score, 0); m.KillEnemy(e); Assert.AreEqual(m.Score, 125); }
public void TestCastleHasHigherHealthOnEasy() { Map m = new Map("normal",1000,1); m.PlaceCastle(c); Assert.AreEqual(125f,m.Castle.Health); }
public void TestCastleHasLowHealthOnHard() { Map m = new Map("normal",1000,3); m.PlaceCastle(c); Assert.AreEqual(75f,m.Castle.Health); }
public void setup() { e = new Enemy(10, 1.0f, "basic", 10, new Rectangle(7, 8, 1, 1)); map = new Map("normal", 10000, 1); map.setStandardEnemy(e);//Allows the map to create waves of this enemy }
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 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 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 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()); }
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); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { this.IsMouseVisible = true; // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load<SpriteFont>("font"); toolTipFont = Content.Load<SpriteFont>("tooltipfont"); bigFont = Content.Load<SpriteFont>("bigFont"); gridSize = 50; gameTimer = 0; placingTower = null; map = new Map("normal", 100, 2); towerTex = Content.Load<Texture2D>("Sprites\\Eiffel"); backTex = Content.Load<Texture2D>("Sprites\\Blank"); Enemy e = new Enemy(100, 10f, "basic", 10, new Rectangle(50, 900, 50, 50)); e.Map = map; map.setStandardEnemy(e.Clone()); map.Enemies.Add(e); Castle c = new Castle(1000000000, new Rectangle(1500, 200, 40, 40)); map.PlaceCastle(c); this.menu = new Interface(this.graphics, this.spriteBatch, this.font); this.menu.Background = backTex; this.menu.TowerTex = towerTex; this.menu.ToolTipFont = toolTipFont; menus = new List<Menu>(); this.main = new Menu("Main Menu", new Point(0, 0), backTex, font, spriteBatch); this.main.Interface = menu; main.AddSubOption("Resume"); main.AddSubOption("Exit Game"); main.Game = this; this.options = new Menu("Options", new Point(0, 250), backTex, font, spriteBatch); this.options.Interface = menu; this.difficulty = new Menu("Difficulty", new Point(0, 500), backTex, font, spriteBatch); this.difficulty.Interface = menu; this.difficulty.AddSubOption("Raise Difficulty"); this.difficulty.AddSubOption("Lower Difficulty"); this.difficulty.AddSubOption("Back"); difficulty.Map = this.map; this.language = new Menu("Languages", new Point(0, 750), backTex, font, spriteBatch); this.language.Interface = menu; this.language.AddSubOption("Spanish"); this.language.AddSubOption("English"); this.language.AddSubOption("Back"); options.AddSubMenu(difficulty); options.AddSubMenu(language); this.options.AddSubOption("Back"); main.AddSubMenu(options); menus.Add(main); menus.Add(options); menus.Add(language); menus.Add(difficulty); Enemy e2 = e.Clone(); //Path creation using towers for (int i = 0; i <= Math.Abs(e2.Location.Y - c.Location.Y) / 50; i++) { Tower t = new Tower("path",10,0,0,1,new Rectangle(50, 900 - Math.Sign(e2.Location.Y - c.Location.Y) * i * 50, 50, 50)); map.PlaceTower(t); } for (int i = 0; i < Math.Abs(e2.Location.X - c.Location.X) / 50; i++) { Tower t = new Tower("path", 10, 0, 0, 1, new Rectangle(50 - Math.Sign(e2.Location.X - c.Location.X) * i * 50,c.Location.Y, 50, 50)); map.PlaceTower(t); } // TODO: use this.Content to load your game content here }
public void SetUp() { map = new Map("normal", 100000, 1); rec = new Rectangle(0, 0, 5, 5); tower = new Tower("basic", 10, 20, 30, 40, new Rectangle(1, 0, 1, 1)); enemy = new Enemy(10, 1.0f, "basic", 20, new Rectangle(rec.X + 5, rec.Y + 5, rec.Width, rec.Height)); wave = new Wave(new Enemy(10, 1.0f, "basic", 20, new Rectangle(rec.X + 5, rec.Y + 5, rec.Width, rec.Height)), 5); map.newWave(wave); map.PlaceTower(tower); }
public void testMapNegativeMoney() { Map m = new Map("normal", -10000, 2); }
public void TestThatScoreIncreasesBy75xGoldOnNormal() { Map m = new Map("normal",100,1); m.SpawnEnemy(e); Assert.AreEqual(m.Score, 0); m.KillEnemy(e); Assert.AreEqual(m.Score, 75); }
public void SetUp() { towerRange = 5; towerPosition = new Rectangle(0, 1, 1, 1); enemyPosition = new Rectangle(1, 1, 1, 1); enemy = new Enemy(10, 1.0f, "basic", 10, enemyPosition); tower = new Tower("Tower", 1, 1, 1, 100, towerPosition); map = new Map("normal", 100, 1); map.PlaceTower(tower); map.SpawnEnemy(enemy); }
public void test0Difficulty() { Map m = new Map("normal", 10000, 0); }
public void EnemiesNotInListThatGetKilledCrashGame() { map = new Map("normal", 0, 1); map.KillEnemy(enemy); }
public void TowersGetRemovedFromListWhenSold() { Tower tower = new Tower("tower", 10, 20, 30, 40, rec); Map map = new Map("normal", 0, 1); map.PlaceTower(tower); map.SellTower(tower); Assert.AreEqual(map.Towers, new List<Tower>()); }
public void testTooHighDifficulty() { Map m = new Map("normal", 10000, 4); }
public void testNegativeDifficulty() { Map m = new Map("normal", 10000, -1); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { this.IsMouseVisible = true; // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); font = Content.Load<SpriteFont>("font"); toolTipFont = Content.Load<SpriteFont>("tooltipfont"); gridSize = 50; gameTimer = 0; placingTower = null; map = new Map("normal", 100, 1); towerTex = Content.Load<Texture2D>("Sprites\\Eiffel"); backTex = Content.Load<Texture2D>("Sprites\\Blank"); Enemy e = new Enemy(100, 10f, "basic", 10, new Rectangle(50, 900, 50, 50)); e.Map = map; map.setStandardEnemy(e.Clone()); map.Enemies.Add(e); map.PlaceCastle(new Castle(1000000000, new Rectangle(1500, 200, 40, 40))); this.menu = new Interface(this.graphics, this.spriteBatch, this.font); this.menu.Background = backTex; this.menu.TowerTex = towerTex; this.menu.ToolTipFont = toolTipFont; menus = new List<Menu>(); this.main = new Menu("Main Menu", new Point(0, 0), backTex, font, spriteBatch); this.main.Interface = menu; main.AddSubOption("Back"); this.options = new Menu("Options", new Point(300, 0), backTex, font, spriteBatch); this.options.Interface = menu; this.options.AddSubOption("Back"); this.difficulty = new Menu("Difficulty", new Point(300, 300), backTex, font, spriteBatch); this.difficulty.Interface = menu; this.difficulty.AddSubOption("Raise Difficulty"); this.difficulty.AddSubOption("Lower Difficulty"); difficulty.Map = this.map; this.language = new Menu("Languages", new Point(600, 0), backTex, font, spriteBatch); this.language.Interface = menu; this.language.AddSubOption("Spanish"); this.language.AddSubOption("English"); this.language.AddSubOption("Back"); options.AddSubMenu(difficulty); options.AddSubMenu(language); main.AddSubMenu(options); menus.Add(main); menus.Add(options); menus.Add(language); menus.Add(difficulty); // TODO: use this.Content to load your game content here }
public void MoneyIncreasesWhenTowerIsSold() { Map map = new Map("normal", 0, 1); Tower tower = new Tower("normal", 10, 20, 30, 40, rec); map.SellTower(tower); Assert.AreEqual(22, map.Money); }
public void Draw(Map.SaveState info) { spriteBatch.Draw(backgroundTexture, this.background, Color.White); foreach (Tower tower in TowerTypes) { spriteBatch.Draw(TowerTextures, tower.Location, Color.White); } Vector2 textLocation = new Vector2(graphics.PreferredBackBufferWidth - 300, graphics.PreferredBackBufferHeight * 4 / 5); spriteBatch.DrawString(font, lm.getTranslation("gold", language) + ": " + info.money, textLocation, Color.Red); spriteBatch.DrawString(font, lm.getTranslation("Speed", language) + ": " + info.score, new Vector2(textLocation.X, textLocation.Y + 25), Color.Red); }
public void testMapInvalidGameType() { Map m = new Map("invalid", 10000, 2); }
public void InsufficientFundsRejectTowerPlacement() { map = new Map("normal", 0, 1); map.PlaceTower(tower); Assert.AreEqual(map.Towers, new List<Tower>()); }
public void MapInitializes() { map = new Map("normal", 0, 1); Assert.IsNotNull(map); }