public void ShouldReturnRandomPickableObject()
        {
            // Arrange
            Coordinates cords = new Coordinates(1, 2);

            // Act
            Pickable result = PickableFactoryProvider.GetRandom(cords);

            // Assert
            Assert.IsInstanceOfType(result, typeof(Pickable));
        }
        public void ShouldReturnPowerDownFactoryThanWhichIs1()
        {
            // Arrange
            int which = 1;

            // Act
            IAbstractPickableFactory result = PickableFactoryProvider.GetFactory(
                which);

            // Assert
            Assert.IsInstanceOfType(result, typeof(PowerDownFactory));
        }
Esempio n. 3
0
        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);
        }