Example #1
0
        public static List <Field> getExplodedFields(Bomb explodedBomb, GameBoard gameBoard, IGameController gameController)
        {
            Field place = explodedBomb.getOwner().Field;

            List <Field> retVals = new List <Field>();

            for (int iX = place.X; iX >= gameBoard.MinX && place.X - iX <= explodedBomb.getExplosiveRadius(); --iX)
            {
                Field currentField = gameBoard.getField(iX, place.Y);
                if (currentField != null && gameController.isExplodable(currentField))
                {
                    retVals.Add(currentField);
                }
                if (!gameController.isExplodable(currentField))
                {
                    break;
                }
            }
            for (int iX = place.X + 1; iX <= gameBoard.MaxX && iX - place.X <= explodedBomb.getExplosiveRadius(); ++iX)
            {
                Field currentField = gameBoard.getField(iX, place.Y);
                if (currentField != null && gameController.isExplodable(currentField))
                {
                    retVals.Add(currentField);
                }
                if (!gameController.isExplodable(currentField))
                {
                    break;
                }
            }

            for (int iY = place.Y - 1; iY >= gameBoard.MinY && place.Y - iY <= explodedBomb.getExplosiveRadius(); --iY)
            {
                Field currentField = gameBoard.getField(place.X, iY);
                if (currentField != null && gameController.isExplodable(currentField))
                {
                    retVals.Add(currentField);
                }
                if (!gameController.isExplodable(currentField))
                {
                    break;
                }
            }
            for (int iY = place.Y + 1; iY <= gameBoard.MaxY && iY - place.Y <= explodedBomb.getExplosiveRadius(); ++iY)
            {
                Field currentField = gameBoard.getField(place.X, iY);
                if (currentField != null && gameController.isExplodable(currentField))
                {
                    retVals.Add(currentField);
                }
                if (!gameController.isExplodable(currentField))
                {
                    break;
                }
            }

            return(retVals);
        }
Example #2
0
 public Explosion(GameBoard gameBoard, Bomb explodedBomb)
 {
     m_radius       = explodedBomb.getExplosiveRadius();
     m_explodedBomb = explodedBomb;
     m_gameBoard    = gameBoard;
 }