Ejemplo n.º 1
0
        public void UpdateExplosives(double time)
        {
            for (int x = 0; x < xSize; x++)
            {
                for (int y = 0; y < ySize; y++)
                {
                    ExplosiveAbstractFactory factory;
                    if (explosions[x, y] is Explosion)
                    {
                        Explosion explosion = (Explosion)explosions[x, y];
                        if (explosion.removalTime < time)
                        {
                            explosions[x, y] = null;
                        }
                    }
                    else if (explosions[x, y] is SuperExplosion)
                    {
                        SuperExplosion explosion = (SuperExplosion)explosions[x, y];
                        if (explosion.removalTime < time)
                        {
                            explosions[x, y] = null;
                        }
                    }
                    if (units[x, y] is Bomb)
                    {
                        factory = new RegularExplosiveConcreteFactory();
                        Bomb bomb = (Bomb)units[x, y];

                        if (bomb.detonationTime < time)
                        {
                            bomb.GetOwner().bombCount++;
                            units[x, y] = null;
                            PlaceRegularExplosion(x, y, bomb.explosionPower, time, factory, bomb.GetOwner());
                        }
                    }
                    else if (units[x, y] is SuperBomb)
                    {
                        factory = new SuperExplosiveConcreteFactory();
                        SuperBomb bomb = (SuperBomb)units[x, y];

                        if (bomb.detonationTime < time)
                        {
                            units[x, y] = null;
                            PlaceSuperExplosion(x, y, bomb.explosionPower, time, factory, bomb.GetOwner());
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void Visit(Explosive explosive)
 {
     if (explosive.explosionPower < 5)
     {
         explosive.explosionPower = 5;
     }
     if (explosive is Bomb)
     {
         Bomb b = (Bomb)explosive;
         b.detonationTime = 0.0;
     }
     else if (explosive is SuperBomb)
     {
         SuperBomb sb = (SuperBomb)explosive;
         sb.detonationTime = 0.0;
     }
 }