public void Road_With_Only_Two_Directions_Has_One_Junction() { //arrange Map map = new Map(); //act map.AddRoad(100, Directions.Right); map.AddRoad(50, Directions.Down); //assert Assert.AreEqual(1, map.Junctions.Count, "Map road has invalid number od junctions."); }
public void Map_End_Road_Position_Is_Equal_To_Sum_Of_Added_Roads() { //arrange Map map = new Map() { RoadThickness = 20, Start = new PointF(0, 0)}; //act map.AddRoad(100, Directions.Right); map.AddRoad(50, Directions.Down); //assert var endX = 100 + 20 / 2; var endY = 50 + 20; Assert.AreEqual(new PointF(endX, endY), map.End, "Road end position is not valid."); }
public void InitGame() { float roadThicknes = 30; float upOffset = 10; game = new Game(20) { Money = 10, Life = 50 }; Level level = new Level() { Count = 10, Money = 5, Speed = 0.6F, Points = 1, SpawnDelayMilis = 1000, Width = 10, Height = 10, HitPoints = 40, Ground = true, Active = true }; game.Levels.Add(level); level = new Level() { Count = 10, Money = 10, Speed = 0.6F, Points = 1, SpawnDelayMilis = 1500, Width = 10, Height = 10, HitPoints = 40, Ground = false, Active = false }; game.Levels.Add(level); level = new Level() { Count = 10, Money = 5, Speed = 0.5F, Points = 1, SpawnDelayMilis = 1000, Width = 10, Height = 10, HitPoints = 60, Ground = true, Active = false }; game.Levels.Add(level); Map map = new Map() { Start = new PointF(0, 10), End = new PointF(450, 170), RoadThickness = 20 }; game.Map = map; map.AddRoad(100, Directions.Right); map.AddRoad(50, Directions.Down); map.AddRoad(50, Directions.Left); map.AddRoad(50, Directions.Down); map.AddRoad(150, Directions.Right); map.AddRoad(100, Directions.Up); map.AddRoad(90, Directions.Right); map.AddRoad(50, Directions.Down); map.AddRoad(130, Directions.Right); map.FlyMiddles.Add(new PointF(200, 30)); map.FlyMiddles.Add(new PointF(200, 50)); map.FlyMiddles.Add(new PointF(200, 70)); // buy towers SimpleTower tower = new SimpleTower() { Center = new PointF(200, 300), Price = 10, Range = 100, TargetType = TargetTypes.All, Active = false, Dummy = true }; game.Towers.Add(tower); SonicTower sonicTower = new SonicTower() { Center = new PointF(250, 300), Price = 50, Range = 100, TargetType = TargetTypes.All, Active = false, Dummy = true }; game.Towers.Add(sonicTower); HeavyTower heavyTower = new HeavyTower() { Center = new PointF(300, 300), Price = 20, Range = 100, SlowDuration = 50, SlowPercent = 50, TargetType = TargetTypes.Ground, Active = false, Dummy = true }; game.Towers.Add(heavyTower); TeslaTower teslaTower = new TeslaTower() { Center = new PointF(350, 300), Price = 20, Range = 150, TargetType = TargetTypes.All, Active = false, Dummy = true }; game.Towers.Add(teslaTower); // active towers tower = new SimpleTower() { Center = new PointF(150, 80), Range = 100, TargetType = TargetTypes.All, Active = true, Placed = true }; game.Towers.Add(tower); sonicTower = new SonicTower() { Center = new PointF(150, 120), Range = 100, TargetType = TargetTypes.All, Active = true, Placed = true }; game.Towers.Add(sonicTower); heavyTower = new HeavyTower() { Center = new PointF(150, 100), Range = 100, SlowDuration = 10, SlowPercent = 50, TargetType = TargetTypes.Ground, Active = true, Placed = true }; game.Towers.Add(heavyTower); teslaTower = new TeslaTower() { Center = new PointF(150, 50), Range = 200, TargetType = TargetTypes.All, Active = true, Placed = true }; game.Towers.Add(teslaTower); game.Running = true; }
public void New_Enemy_Added_To_Map_Gets_Positioned_On_Road_Start() { //arrange var start = new PointF(10, 20); Map map = new Map() { Start = start }; map.AddRoad(100, Directions.Right); BaseEnemy enemy = new GroundEnemy(1.3F, 1, 1, null); //act map.PositionEnemyForStart(enemy); //assert Assert.AreEqual(new PointF(10.1f, 20), enemy.Center, "Failed to position new ground enemy to map road start."); }