public void Should_ReturnTrue_When_Kick(Explosive.KickDirection dir) { //Arrange GameArena arena = new GameArena(0); Explosive bomb = new Explosive(1, 1); // Act arena.gameObjects.Add(bomb); //Assert Assert.IsTrue(arena.KickBomb(bomb.GetCords(), dir)); }
public void Should_ReturnFalse_When_Kick(int x, int y, Explosive.KickDirection dir) { //Arrange GameArena arena = new GameArena(0); Explosive bomb = new Explosive(x, y); // Act arena.gameObjects.Add(bomb); //Assert Assert.IsFalse(arena.KickBomb(bomb.GetCords(), dir)); }
public void ShouldSetandGetCordsCoordinates() { // Arrange Explosive explosive = this.CreateExplosive(); // Act explosive.SetCords(this.cords.Object); Coordinates result = explosive.GetCords(); // Assert Assert.AreEqual(this.cords.Object, result); }
private async void RemoveBomb(Explosive bomb, Player player) { await Task.Factory.StartNew(() => { var fc = new PowerUpFactory(); Thread.Sleep(bomb.Time); Coordinates xy = bomb.GetCords(); context.grid.RemoveFromTile(xy.X, xy.Y, (int)TileTypeEnum.Bomb); context.RemoveGameObject(bomb, xy.X, xy.Y); ExecuteExplosion(bomb); context.UpdateRequired = true; player.BombCount--; }); }
private void ExecuteExplosion(Explosive bomb) { Flame flames = new Flame(bomb.GetCords()); flames.flames[bomb.GetCords().X, bomb.GetCords().Y] = (int)TileTypeEnum.FlameC; context.grid.ReturnPlayersAt(bomb.GetCords().X, bomb.GetCords().Y).ForEach(z => context.Players[z - 1].Alive = false); int x = ((Coordinates)bomb.GetCords().Clone()).X; int y = ((Coordinates)bomb.GetCords().Clone()).Y; int radius = bomb.Radius; for (int i = 1; i < radius; i++) { if ((x - i) >= 0) { if (context.walls[x - i, y] == (int)TileTypeEnum.Wall) { break; } if (context.walls[x - i, y] == (int)TileTypeEnum.DestroyableWall) { context.grid.AddToTile(x - i, y, (int)TileTypeEnum.FlameH); context.walls[x - i, y] = 0; var temp = PickableFactoryProvider.GetRandom(new Coordinates(x - i, y)); if (!(temp is null)) { context.AddGameObject(temp); } break; } context.grid.ReturnPlayersAt(x - i, y).ForEach(z => context.Players[z - 1].Alive = false); bool brk = false; context.grid.ReturnPowersAt(x - i, y).ForEach(z => { context.RemoveGameObjectAt(x - i, y); brk = true; }); flames.flames[x - i, y] = (int)TileTypeEnum.FlameH; if (brk) { break; } } } for (int i = 1; i < radius; i++) { if ((x + i) <= 12) { if (context.walls[x + i, y] == (int)TileTypeEnum.Wall) { break; } if (context.walls[x + i, y] == (int)TileTypeEnum.DestroyableWall) { context.walls[x + i, y] = 0; var temp = PickableFactoryProvider.GetRandom(new Coordinates(x + i, y)); if (!(temp is null)) { context.AddGameObject(temp); } break; } context.grid.ReturnPlayersAt(x + i, y).ForEach(x => context.Players[x - 1].Alive = false); bool brk = false; context.grid.ReturnPowersAt(x + i, y).ForEach(z => { context.RemoveGameObjectAt(x + i, y); brk = true; }); flames.flames[x + i, y] = (int)TileTypeEnum.FlameH; if (brk) { break; } } } for (int i = 1; i < radius; i++) { if ((y - i) >= 0) { if (context.walls[x, y - i] == (int)TileTypeEnum.Wall) { break; } if (context.walls[x, y - i] == (int)TileTypeEnum.DestroyableWall) { context.walls[x, y - i] = 0; var temp = PickableFactoryProvider.GetRandom(new Coordinates(x, y - i)); if (!(temp is null)) { context.AddGameObject(temp); } break; } context.grid.ReturnPlayersAt(x, y - i).ForEach(x => context.Players[x - 1].Alive = false); bool brk = false; context.grid.ReturnPowersAt(x, y - i).ForEach(z => { context.RemoveGameObjectAt(x, y - i);; brk = true; }); flames.flames[x, y - i] = (int)TileTypeEnum.FlameV; if (brk) { break; } } } for (int i = 1; i < radius; i++) { if ((y + i) <= 12) { if (context.walls[x, y + i] == (int)TileTypeEnum.Wall) { break; } if (context.walls[x, y + i] == (int)TileTypeEnum.DestroyableWall) { context.walls[x, y + i] = 0; var temp = PickableFactoryProvider.GetRandom(new Coordinates(x, y + i)); if (!(temp is null)) { context.AddGameObject(temp); } break; } context.grid.ReturnPlayersAt(x, y + i).ForEach(x => context.Players[x - 1].Alive = false); bool brk = false; context.grid.ReturnPowersAt(x, y + i).ForEach(z => { context.RemoveGameObjectAt(x, y + i); brk = true; }); flames.flames[x, y + i] = (int)TileTypeEnum.FlameV; if (brk) { break; } } } FlamesAtInterval(flames, Constants.FlameExposureTime); }