Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        private bool getTargetField(int inX, int inY, AIStep.MoveEnum step, out Field target)
        {
            int  tx = 0, ty = 0;
            bool ret = true;

            target = null;

            ret = moveCoordinates(inX, inY, step, out tx, out ty);
            if (ret == false)
            {
                return(false);
            }

            target = m_gameBoard.getField(tx, ty) as Field;
            if (target == null)
            {
                ret = false;
            }
            return(ret);
        }