Exemplo n.º 1
0
 private void PlaceSuperExplosion(int xTile, int yTile, int explosionPower, double placeTime, ExplosiveAbstractFactory factory, Player owner)
 {
     if (explosionPower > 4)
     {
         explosionPower = 4;
     }
     else if (explosionPower < 2)
     {
         explosionPower = 2;
     }
     for (int x = Math.Max(1, xTile - explosionPower); x <= Math.Min(xTile + explosionPower, xSize - 2); x++)
     {
         for (int y = Math.Max(1, yTile - explosionPower); y <= Math.Min(yTile + explosionPower, ySize - 2); y++)
         {
             if (units[x, y] == null || explosions[x, y] is Explosion || explosions[x, y] is SuperExplosion || units[x, y].isSolid == false)
             {
                 explosions[x, y] = factory.CreateExplosion(x, y, placeTime, owner);
             }
             else if (units[x, y] is Box)
             {
                 units[x, y]      = null;
                 explosions[x, y] = factory.CreateExplosion(x, y, placeTime, owner);
             }
         }
     }
 }
Exemplo n.º 2
0
 private bool RegularExplosionCreation(int x, int y, double placeTime, bool isFinished, ExplosiveAbstractFactory factory, Player owner)
 {
     if (units[x, y] == null || explosions[x, y] is Explosion || explosions[x, y] is SuperExplosion || units[x, y].isSolid == false)
     {
         explosions[x, y] = factory.CreateExplosion(x, y, placeTime, owner);
     }
     else
     {
         if (units[x, y] is Box)
         {
             Random rand = new Random();
             int    n    = rand.Next(100);
             //FOR TESTING
             if (n < 100)
             {
                 units[x, y] = PickBoostStrategy(x, y);
             }
             else
             {
                 units[x, y] = null;
             }
             explosions[x, y] = factory.CreateExplosion(x, y, placeTime, owner);
         }
         isFinished = true;
     }
     return(isFinished);
 }
Exemplo n.º 3
0
        private void PlaceRegularExplosion(int xTile, int yTile, int explosionPower, double placeTime, ExplosiveAbstractFactory factory, Player owner)
        {
            bool topFinished    = false;
            bool bottomFinished = false;
            bool leftFinished   = false;
            bool rightFinished  = false;

            explosions[xTile, yTile] = factory.CreateExplosion(xTile, yTile, placeTime, owner);

            for (int i = 1; i < explosionPower; i++)
            {
                if (!topFinished)
                {
                    topFinished = RegularExplosionCreation(xTile, yTile - i, placeTime, topFinished, factory, owner);
                }
                if (!bottomFinished)
                {
                    bottomFinished = RegularExplosionCreation(xTile, yTile + i, placeTime, bottomFinished, factory, owner);
                }
                if (!leftFinished)
                {
                    leftFinished = RegularExplosionCreation(xTile - i, yTile, placeTime, leftFinished, factory, owner);
                }
                if (!rightFinished)
                {
                    rightFinished = RegularExplosionCreation(xTile + i, yTile, placeTime, rightFinished, factory, owner);
                }
            }
        }