public void testTowerGetsRange() { Tower tower= new Tower(); t.setRange = 10; Assert.AreEqual(t.Range, 10); }
public void testTowerGetsAttackDamage() { Tower tower= new Tower(); t.setAttackDamage = 10; Assert.AreEqual(t.AttackDamage, 10); }
public void testTowerGetsHealth() { Tower tower = new Tower(); tower.setHealth = 10; Assert.AreEqual(tower.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 towerGetsEnemy() { Enemy enemy = new Enemy(0, 0.0f, "", 0); tower = new Tower("", 0, 0, 0, 0); tower.AddNearbyEnemy(enemy); Assert.AreSame(enemy, tower.Enemies(0)); }
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 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 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 testTowerGetsCost() { Tower tower= new Tower(); t.setCost = 10; Assert.AreEqual(t.Cost, 10); }
public void setUp() { tower = new Tower("basic", 10, 10, 10, 10, new Rectangle(5, 6, 1, 1)); e = new Enemy(10, 1.0f, "basic", 10, new Rectangle(7, 8, 1, 1)); c = new Castle(100, new Rectangle(8, 8, 1, 1)); }
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 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); }
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 EnemyThatDiesWithinRangeOfTwoTowersGetsRemovedFromBothTowerLists() { Tower tower2 = new Tower("Tower2", 10, 1, 1, 50, new Rectangle(2, 2, 1, 1)); //Second tower; enemy should still be within its range map.PlaceTower(tower2); enemy.Health = 2; //Manually set the enemy's health to 2 for the case of this test map.Update(); //Update method for map cases both of the towers to add nearby enemies Assert.AreEqual(tower.Enemies.Count, 1); //Verify that the first tower's list of enemies has one enemy Assert.AreEqual(tower2.Enemies.Count, 1); //Verify that the second tower's list of enemies has one enemy tower.AttackEnemy(enemy); //Update the first tower to attack the enemy tower2.AttackEnemy(enemy); //Update the second tower to attack (and thereby killing) the enemy map.Update(); //Update method for map causes both of the towers to update their list of nearby enemies\ Assert.AreEqual(tower.Enemies.Count, 0); //Verify that the first tower's list of enemies is empty Assert.AreEqual(tower2.Enemies.Count, 0); //Verify that the second tower's list of enemies is empty }
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 testInit() { tower = new Tower("", 1,10, 10, 10, rec); Assert.IsNotNull(tower); }
public void towerHasCorrectRangeWhenInitialized() { tower= new Tower("",10, 20, 30, 40, rec); Assert.AreEqual(tower.Range, 40); }
public void towerHasCorrectHealthWhenInitialized() { tower = new Tower("", 10, 20,30,40, rec); Assert.AreEqual(tower.Health,10); }
public void towerHasCorrectHealthAfterModified() { tower = new Tower("", 10, 20,30,40, rec); tower.Health -= 1; Assert.AreEqual(tower.Health,9); }
public void testTowerThrowsExceptioOnZeroDamage() { Tower t = new Tower("tower", 10, 0, 10, 10, new Rectangle(0, 0, 10, 10)); }
/// <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 }
/// <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 }
//Sells a tower, adding .75 times its original cost to the bank (8 lines) public void SellTower(Tower tower) { towersOnMap.Remove(tower); money += (int)(tower.Cost * 0.75); }
public void testTowerThrowsExceptioOnNegativeRange() { Tower t = new Tower("tower", 10, 10, 10, -10, new Rectangle(0, 0, 10, 10)); }
public void testTowerThrowsExceptioOnNullArea() { Tower t = new Tower("tower", 10, 10, 10, 10, new Rectangle()); }
public void towerHasCorrectAttackDamageWhenInitialized() { tower= new Tower("",10,20,30,40, rec); Assert.AreEqual(tower.AttackDamage, 20); }
public void testTowerInit() { Tower tower = new Tower("Tower",1,1,1,1); Assert.IsNotNull(tower); }
public void towerHasCorrectCostWhenInitialized() { tower= new Tower("",10,20,30,40, rec ); Assert.AreEqual(tower.Cost, 30); }
public void UpdateInput() { mouseState = Mouse.GetState(); boardState = Keyboard.GetState(); if (placingTower != null) { placingTower.Location = new Rectangle(mouseState.X - (mouseState.X % gridSize), mouseState.Y - (mouseState.Y % gridSize), placingTower.Location.Width, placingTower.Location.Height); if (mouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton == ButtonState.Released) { for (int i = 0; i < map.Towers.Count; i++) { } map.PlaceTower(new Tower(placingTower.Name, placingTower.Health, placingTower.AttackDamage, placingTower.Cost, placingTower.Range, placingTower.Location)); placingTower = null; } } else { if (mouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton == ButtonState.Released) { foreach (Tower tower in menu.Towers) { if (tower.Location.Contains(mouseState.X, mouseState.Y)) placingTower = tower.Clone(); } } } if (mouseState.RightButton == ButtonState.Pressed && previousMouseState.RightButton == ButtonState.Released) { for (int i = 0; i < map.Towers.Count; i++) { if (map.Towers[i].Location.Contains(mouseState.X, mouseState.Y)) { map.SellTower(map.Towers[i]); } } } #region Selecting towers with Keyboard Input if (boardState.IsKeyDown(Keys.D1) && previousKeyboardState.IsKeyUp(Keys.D1)) { Tower temp = menu.Towers[0]; placingTower = new Tower(temp.Name, temp.Health, temp.AttackDamage, temp.Cost, temp.Range, new Rectangle(mouseState.X - (mouseState.X % gridSize), mouseState.Y - (mouseState.Y % gridSize), 50, 50)); } if (boardState.IsKeyDown(Keys.D2) && previousKeyboardState.IsKeyUp(Keys.D2)) { Tower temp = menu.Towers[1]; placingTower = new Tower(temp.Name, temp.Health, temp.AttackDamage, temp.Cost, temp.Range, new Rectangle(mouseState.X - (mouseState.X % gridSize), mouseState.Y - (mouseState.Y % gridSize), 50, 50)); } #endregion if (boardState.IsKeyUp(Keys.LeftAlt)) { rewindingTime = false; map.Rewinding = false; map.SaveNextState(); } if (boardState.IsKeyDown(Keys.LeftAlt)) { map.Rewinding = true; rewindingTime = true; map.LoadPreviousState(); } #region Menu interaction if (boardState.IsKeyDown(Keys.Escape) && previousKeyboardState.IsKeyUp(Keys.Escape)) { main.Visible = !main.Visible; } if (mouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton == ButtonState.Released) { foreach (Menu item in menus) { if (item.Visible) item.RegisterClick(new Point(mouseState.X, mouseState.Y)); } } #endregion previousMouseState = mouseState; previousKeyboardState = boardState; }
public void UpdateInput() { mouseState = Mouse.GetState(); boardState = Keyboard.GetState(); if (placingTower != null) { placingTower.Location = new Rectangle(mouseState.X - (mouseState.X % gridSize), mouseState.Y - (mouseState.Y % gridSize), placingTower.Location.Width, placingTower.Location.Height); if (mouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton == ButtonState.Released) { for (int i = 0; i < map.Towers.Count; i++) { } map.PlaceTower(new Tower(placingTower.Name, placingTower.Health, placingTower.AttackDamage, placingTower.Cost, placingTower.Range, placingTower.Location)); placingTower = null; } } else { if (mouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton == ButtonState.Released) { foreach (Tower tower in menu.Towers) { if (tower.Location.Contains(mouseState.X, mouseState.Y)) { placingTower = tower.Clone(); } } } } if (mouseState.RightButton == ButtonState.Pressed && previousMouseState.RightButton == ButtonState.Released) { for (int i = 0; i < map.Towers.Count; i++) { if (map.Towers[i].Location.Contains(mouseState.X, mouseState.Y)) { map.SellTower(map.Towers[i]); } } } #region Selecting towers with Keyboard Input if (boardState.IsKeyDown(Keys.D1) && previousKeyboardState.IsKeyUp(Keys.D1)) { Tower temp = menu.Towers[0]; placingTower = new Tower(temp.Name, temp.Health, temp.AttackDamage, temp.Cost, temp.Range, new Rectangle(mouseState.X - (mouseState.X % gridSize), mouseState.Y - (mouseState.Y % gridSize), 50, 50)); } if (boardState.IsKeyDown(Keys.D2) && previousKeyboardState.IsKeyUp(Keys.D2)) { Tower temp = menu.Towers[1]; placingTower = new Tower(temp.Name, temp.Health, temp.AttackDamage, temp.Cost, temp.Range, new Rectangle(mouseState.X - (mouseState.X % gridSize), mouseState.Y - (mouseState.Y % gridSize), 50, 50)); } #endregion if (boardState.IsKeyUp(Keys.LeftAlt)) { rewindingTime = false; map.Rewinding = false; map.SaveNextState(); } if (boardState.IsKeyDown(Keys.LeftAlt)) { map.Rewinding = true; rewindingTime = true; map.LoadPreviousState(); } #region Menu interaction if (boardState.IsKeyDown(Keys.Escape) && previousKeyboardState.IsKeyUp(Keys.Escape)) { main.Visible = !main.Visible; } if (mouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton == ButtonState.Released) { foreach (Menu item in menus) { if (item.Visible) { item.RegisterClick(new Point(mouseState.X, mouseState.Y)); } } } #endregion previousMouseState = mouseState; previousKeyboardState = boardState; }
public void testInit() { tower = new Tower("", 0, 0, 0, 0); Assert.IsNotNull(tower); }