示例#1
0
    private void CreateBonus(GameObject go, MatchesInfo matchesInfo)
    {
        Shape     hitGoCache = go.GetComponent <Shape>();
        BonusType bonusType  = BonusType.None;

        if ((matchesInfo.HorizontalMatches >= Constants.MinimumMatchesForUltimate) ||
            (matchesInfo.VerticalMatches >= Constants.MinimumMatchesForUltimate))
        {
            bonusType = BonusType.Ultimate;
        }
        else if ((matchesInfo.HorizontalMatches == Constants.MinimumMatchesForBonus) &&
                 (matchesInfo.HorizontalMatches > matchesInfo.VerticalMatches))
        {
            bonusType = BonusType.Vertical;
        }
        else if ((matchesInfo.VerticalMatches == Constants.MinimumMatchesForBonus) &&
                 (matchesInfo.VerticalMatches > matchesInfo.HorizontalMatches))
        {
            bonusType = BonusType.Horizontal;
        }
        else
        {
            bonusType = BonusType.Bomb;
        }

        InstantiateAndPlaceNewCandy(hitGoCache.Row, hitGoCache.Column, GetPrefabFromTypeAndBonus(hitGoCache.Type, bonusType), bonusType);
    }
示例#2
0
    /// <summary>
    /// Returns the matches found for a single GameObject
    /// </summary>
    /// <param name="go"></param>
    /// <returns></returns>
    public MatchesInfo GetMatches(GameObject go)
    {
        MatchesInfo matchesInfo = new MatchesInfo();

        var horizontalMatches = GetMatchesHorizontally(go);

        if (ContainsDestroyRowColumnBonus(horizontalMatches))
        {
            horizontalMatches = GetEntireRow(go);
            if (!BonusTypeUtilities.ContainsDestroyWholeRowColumn(matchesInfo.BonusesContained))
            {
                matchesInfo.BonusesContained |= BonusType.DestroyWholeRowColumn;
            }
        }
        matchesInfo.AddObjectRange(horizontalMatches);

        var verticalMatches = GetMatchesVertically(go);

        if (ContainsDestroyRowColumnBonus(verticalMatches))
        {
            verticalMatches = GetEntireColumn(go);
            if (!BonusTypeUtilities.ContainsDestroyWholeRowColumn(matchesInfo.BonusesContained))
            {
                matchesInfo.BonusesContained |= BonusType.DestroyWholeRowColumn;
            }
        }
        matchesInfo.AddObjectRange(verticalMatches);

        return(matchesInfo);
    }
示例#3
0
    public MatchesInfo getMatches(GameObject go1, GameObject go2)
    {
        MatchesInfo matchesInfo = new MatchesInfo();
        var         matches     = GetAllMatches(go1, go2);

        matchesInfo.AddObjectRange(matches);
        return(matchesInfo);
    }
示例#4
0
    public MatchesInfo GetAllShapes()
    {
        MatchesInfo matchesInfo = new MatchesInfo();

        foreach (var item in shapes)
        {
            matchesInfo.AddObject(item);
        }

        return(matchesInfo);
    }
示例#5
0
    public MatchesInfo GetMatches(GameObject obj)
    {
        MatchesInfo matchesInfo = new MatchesInfo();

        var horizontalMatches = GetMatchesHorizontally(obj);

        matchesInfo.AddObjectRange(horizontalMatches);

        var verticalMatches = GetMatchesVertically(obj);

        matchesInfo.AddObjectRange(verticalMatches);

        return(matchesInfo);
    }
示例#6
0
    } // GetEmptyItemsOnColumn()

    /// <summary>
    /// Get all the matches adjacent to the candy
    /// </summary>
    /// <param name="obj"></param>
    /// <returns></returns>
    public MatchesInfo GetMatches(GameObject obj)
    {
        MatchesInfo matchesInfo = new MatchesInfo();

        // Get any horizontal matches adjacent to the passed object
        var horizontalMatches = GetMatchesHorizontally(obj);

        // Does the match contain a bonus bean that destroys the entire row + column?
        if (ContainsDestroyWholeRowColumnBonus(horizontalMatches))
        {
            // if yes, then get all the objects in the row.
            horizontalMatches = GetEntireRow(obj);

            // if the matches info doesn't have the info about the bonus, make sure it does.
            if (!BonusTypeChecker.ContainsDestroyWholeWorColumn(matchesInfo.BonusesContained))
            {
                matchesInfo.BonusesContained = BonusType.DestroyWholeRowColumn;
            }
        }

        // Add all the row matches to the list
        matchesInfo.AddObjectRange(horizontalMatches);

        // ==== Now do the same for vertical column ====


        // Get any horizontal matches adjacent to the passed object
        var verticalMatches = GetMatchesVertically(obj);

        // Does the match contain a bonus bean that destroys the entire row + column?
        if (ContainsDestroyWholeRowColumnBonus(verticalMatches))
        {
            // if yes, then get all the objects in the column.
            verticalMatches = GetEntireColumn(obj);

            // if the matches info doesn't have the info about the bonus, make sure it does.
            if (!BonusTypeChecker.ContainsDestroyWholeWorColumn(matchesInfo.BonusesContained))
            {
                matchesInfo.BonusesContained = BonusType.DestroyWholeRowColumn;
            }
        }

        // Add all the vertical matches to the list
        matchesInfo.AddObjectRange(verticalMatches);

        // return the list of all matched candies
        return(matchesInfo);
    }
示例#7
0
    private void CheckForScoreAndIncrease(MatchesInfo item, ref bool[,] matchScoreCounted, int matchScore, int timesRun)
    {
        bool countScore = true;

        foreach (var go in item.MatchedCandy)
        {
            if (matchScoreCounted[go.GetComponent <Shape>().Row, go.GetComponent <Shape>().Column] == true)
            {
                countScore = false;
            }
        }
        if (countScore == true)
        {
            List <float> xPositions = new List <float>();
            List <float> yPositions = new List <float>();
            foreach (var go in item.MatchedCandy)
            {
                matchScoreCounted[go.GetComponent <Shape>().Row, go.GetComponent <Shape>().Column] = true;
                xPositions.Add(Camera.main.WorldToScreenPoint(go.transform.position).x);
                yPositions.Add(Camera.main.WorldToScreenPoint(go.transform.position).y);
            }
            var   xSorted = xPositions.OrderBy(n => n);
            var   ySorted = yPositions.OrderBy(n => n);
            float xMedian = 0.0f;
            float yMedian = 0.0f;
            if ((item.Matches % 2) == 0)
            {
                xMedian = ((xSorted.ElementAt(item.Matches / 2) + xSorted.ElementAt(item.Matches / 2 - 1)) / 2);
                yMedian = ((ySorted.ElementAt(item.Matches / 2) + ySorted.ElementAt(item.Matches / 2 - 1)) / 2);
            }
            else
            {
                xMedian = xSorted.ElementAt(item.Matches / 2);
                yMedian = ySorted.ElementAt(item.Matches / 2);
            }
            Vector3 position   = new Vector3(xMedian, yMedian, 0.0f);
            int     addedScore = matchScore + timesRun * Constants.ConsecutiveMatchScore;
            IncreaseScoreAndCreatePopUp(addedScore, position);
        }
    }
示例#8
0
    public MatchesInfo GetMatches(GameObject go, GameObject go2 = null)
    {
        BonusType goBonus  = go.GetComponent <Shape>().Bonus;
        BonusType go2Bonus = BonusType.None;

        if (go2 != null)
        {
            go2Bonus = go2.GetComponent <Shape>().Bonus;
        }

        MatchesInfo matchesInfo = new MatchesInfo
        {
            OriginGameObject = go
        };

        bool[,] bonusUsed = new bool[Constants.Rows, Constants.Columns];
        for (int i = 0; i < Constants.Rows; i++)
        {
            for (int j = 0; j < Constants.Columns; j++)
            {
                bonusUsed[i, j] = false;
            }
        }
        if (goBonus == BonusType.Ultimate)
        {
            if (go2Bonus == BonusType.Ultimate)
            {
                matchesInfo = GetAllShapes();
                matchesInfo.DestroyedByBonus = true;
            }
        }
        else
        {
            if (go2Bonus == BonusType.Ultimate)
            {
                matchesInfo.AddObject(go2);
                foreach (var item in shapes)
                {
                    if (item.GetComponent <Shape>().Type == go.GetComponent <Shape>().Type)
                    {
                        matchesInfo.AddObject(item);
                    }
                }
                matchesInfo.DestroyedByBonus = true;
            }
            else if ((goBonus == BonusType.Bomb) && (go2Bonus == BonusType.Bomb))
            {
                go.GetComponent <Shape>().Bonus  = BonusType.None;
                go2.GetComponent <Shape>().Bonus = BonusType.None;
                matchesInfo.AddObjectRange(GetBombRadius(go, 2));
                matchesInfo.AddObjectRange(GetBombRadius(go2, 2));
                matchesInfo.DestroyedByBonus = true;
            }
            else if (((goBonus == BonusType.Vertical) || (goBonus == BonusType.Horizontal)) &&
                     ((go2Bonus == BonusType.Vertical) || (go2Bonus == BonusType.Horizontal)))
            {
                go.GetComponent <Shape>().Bonus  = BonusType.None;
                go2.GetComponent <Shape>().Bonus = BonusType.None;
                matchesInfo.AddObjectRange(GetEntireColumn(go));
                matchesInfo.AddObjectRange(GetEntireRow(go));
                matchesInfo.DestroyedByBonus = true;
            }
            else if (((goBonus == BonusType.Vertical) || (goBonus == BonusType.Horizontal)) &&
                     (go2Bonus == BonusType.Bomb))
            {
                matchesInfo.AddObjectRange(GetBombAndVerticalOrHorizontal(go, go2));
                matchesInfo.DestroyedByBonus = true;
            }
            else if ((goBonus == BonusType.Bomb) &&
                     ((go2Bonus == BonusType.Vertical) || (go2Bonus == BonusType.Horizontal)))
            {
                matchesInfo.AddObjectRange(GetBombAndVerticalOrHorizontal(go, go2));
                matchesInfo.DestroyedByBonus = true;
            }
            else
            {
                var horizontalMatches = GetMatchesHorizontally(go);
                matchesInfo.AddObjectRange(horizontalMatches);
                matchesInfo.HorizontalMatches = horizontalMatches.Count();

                var verticalMatches = GetMatchesVertically(go);
                matchesInfo.AddObjectRange(verticalMatches);
                matchesInfo.VerticalMatches = verticalMatches.Count();
            }

            bool containsBonuses = false;

            do
            {
                containsBonuses = false;

                List <GameObject> temp = new List <GameObject>(matchesInfo.MatchedCandy);
                foreach (var item in temp)
                {
                    Shape shape = item.GetComponent <Shape>();
                    switch (shape.Bonus)
                    {
                    case BonusType.Horizontal:
                        bonusUsed[shape.Row, shape.Column] = true;
                        shape.Bonus = BonusType.None;
                        matchesInfo.AddObjectRange(GetEntireRow(item));
                        matchesInfo.DestroyedByBonus = true;
                        break;

                    case BonusType.Vertical:
                        bonusUsed[shape.Row, shape.Column] = true;
                        shape.Bonus = BonusType.None;
                        matchesInfo.AddObjectRange(GetEntireColumn(item));
                        matchesInfo.DestroyedByBonus = true;
                        break;

                    case BonusType.Bomb:
                        bonusUsed[shape.Row, shape.Column] = true;
                        shape.Bonus = BonusType.None;
                        matchesInfo.AddObjectRange(GetBombRadius(item, 1));
                        matchesInfo.DestroyedByBonus = true;
                        break;

                    case BonusType.Ultimate:
                        bonusUsed[shape.Row, shape.Column] = true;
                        break;

                    default:
                        break;
                    }
                }

                foreach (var item in matchesInfo.MatchedCandy)
                {
                    Shape shape = item.GetComponent <Shape>();

                    if (bonusUsed[shape.Row, shape.Column] == true)
                    {
                        shape.Bonus = BonusType.None;
                    }

                    if (shape.Bonus != BonusType.None)
                    {
                        containsBonuses = true;
                    }
                }
            } while (containsBonuses == true);
        }

        return(matchesInfo);
    }
示例#9
0
    // Checks for horizontal matches
    public MatchesInfo GetMatches(GameObject go)
    {
        MatchesInfo matchesInfo = new MatchesInfo();

        var horizontalMatches = GetMatchesHorizontally(go);
        if (ContainsDestroyRowColumnBonus(horizontalMatches))
        {
            horizontalMatches = GetEntireRow(go);
            if (!BonusTypeUtilities.ContainsDestroyWholeRowColumn(matchesInfo.BonusesContained))
            {
                matchesInfo.BonusesContained |= BonusType.DestroyWholeRowColumn;
            }
        }
        matchesInfo.AddObjectRange(horizontalMatches);

        var verticalMatches = GetMatchesVertically(go);
        if (ContainsDestroyRowColumnBonus(verticalMatches))
        {
            verticalMatches = GetEntireColumn(go);
            if (!BonusTypeUtilities.ContainsDestroyWholeRowColumn(matchesInfo.BonusesContained))
            {
                matchesInfo.BonusesContained |= BonusType.DestroyWholeRowColumn;
            }
        }
        matchesInfo.AddObjectRange(verticalMatches);

        return matchesInfo;
    }
示例#10
0
        public async Task <int> AddMatchesInfoAsync()
        {
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            var parser    = new HtmlParser();
            var webClient = new WebClient {
                Encoding = Encoding.GetEncoding("windows-1251")
            };

            for (var i = 1; i <= 2; i++)
            {
                var    url  = $"https://www.futbol24.com/national/Bulgaria/A-Grupa/2020-2021/results/?statLR-Page={i}";
                string html = null;
                for (var j = 0; j < 20; j++)
                {
                    try
                    {
                        html = webClient.DownloadString(url);
                        break;
                    }
                    catch (Exception)
                    {
                        Thread.Sleep(1000);
                    }
                }

                if (string.IsNullOrWhiteSpace(html))
                {
                    continue;
                }

                var document    = parser.ParseDocument(html);
                var ResultTable = document.GetElementsByClassName("stat2");
                var test        = ResultTable.Length;

                foreach (var tr in ResultTable)
                {
                    var DateTime   = tr.GetElementsByClassName("timezonebar").Length;
                    var MatchCount = tr.GetElementsByClassName("status5").Length;

                    for (int n = 0; n < MatchCount; n++)
                    {
                        var Match     = tr.GetElementsByClassName("status5")[n];
                        var MatchDate = Match.GetElementsByClassName("timezone")[0].OuterHtml.Split("title");

                        var DateSplit        = MatchDate[1].Split("=");
                        var DateSplitBySpace = DateSplit[1].Split(' ');
                        var DateReplace      = Regex.Replace(DateSplitBySpace[0], @"[^0-9:,]+", " ");
                        var Date             = Convert.ToDateTime(DateReplace, new CultureInfo("fr-FR"));
                        var League           = Match.GetElementsByClassName("comp")[0].TextContent;
                        var HomeTeam         = Match.GetElementsByClassName("team4")[0].TextContent;
                        var Result           = Match.GetElementsByClassName("dash")[0].TextContent.Split('-');
                        var HomeTeamResult   = int.Parse(Result[0]);
                        var AwayTeamResult   = int.Parse(Result[1]);
                        var AwayTeam         = Match.GetElementsByClassName("team5")[0].TextContent;
                        var winner           = "draw";

                        if (HomeTeamResult > AwayTeamResult)
                        {
                            winner = HomeTeam;
                        }
                        else if (HomeTeamResult < AwayTeamResult)
                        {
                            winner = AwayTeam;
                        }

                        var addMatchesInfo = new MatchesInfo
                        {
                            HomeTeam       = HomeTeam,
                            AwayTeam       = AwayTeam,
                            HomeTeamResult = HomeTeamResult,
                            AwayTeamResult = AwayTeamResult,
                            Winner         = winner,
                            Date           = Date,
                        };

                        await this.matchRepository.AddAsync(addMatchesInfo);
                    }
                }
            }

            await this.gameRepository.SaveChangesAsync();

            return(1);
        }
示例#11
0
    public IEnumerator ConvertBlock(GameObject block, GameObject convertTo)
    {
        bool isBall   = false;
        bool isRef    = false;
        bool isBlue   = false;
        bool isGreen  = false;
        bool isRed    = false;
        bool isCoin   = false;
        bool isGoalie = false;

        int numBalls   = 0;
        int numRefs    = 0;
        int numBlues   = 0;
        int numGreens  = 0;
        int numReds    = 0;
        int numCoins   = 0;
        int numGoalies = 0;

        var sameBlocks = shapes.GetBlockInEntireBoard(block);
        List <GameObject>        convertedBlocks = new List <GameObject>();
        IEnumerable <GameObject> totalMatches;

        foreach (var item in sameBlocks)
        {
            int row    = item.GetComponent <Shape>().Row;
            int column = item.GetComponent <Shape>().Column;
            shapes.Remove(item);
            RemoveFromScene(item);
            convertedBlocks.Add(InstantiateAndPlaceConverted(row, column, convertTo));
        }

        yield return(new WaitForSeconds(0.2f));

        foreach (GameObject c in convertedBlocks)
        {
            if (c != null)
            {
                //get the matches via the helper methods
                MatchesInfo convertMatchesInfo = shapes.GetMatches(c);

                totalMatches = convertMatchesInfo.MatchedBlock;


                while (totalMatches.Count() >= Constants.MinimumMatches)
                {
                    isBall   = false;
                    isRef    = false;
                    isBlue   = false;
                    isGreen  = false;
                    isRed    = false;
                    isCoin   = false;
                    isGoalie = false;

                    numBalls   = 0;
                    numRefs    = 0;
                    numBlues   = 0;
                    numGreens  = 0;
                    numReds    = 0;
                    numCoins   = 0;
                    numGoalies = 0;

                    soundManager.PlayCrincle();

                    foreach (var item in totalMatches)
                    {
                        if (item.GetComponent <Shape>().Type == "Ball")
                        {
                            isBall = true;
                            numBalls++;
                        }
                        else if (item.GetComponent <Shape>().Type == "Ref")
                        {
                            isRef = true;
                            numRefs++;
                        }
                        else if (item.GetComponent <Shape>().Type == "player_blue")
                        {
                            isBlue = true;
                            numBlues++;
                        }
                        else if (item.GetComponent <Shape>().Type == "player_green")
                        {
                            isGreen = true;
                            numGreens++;
                        }
                        else if (item.GetComponent <Shape>().Type == "player_red")
                        {
                            isRed = true;
                            numReds++;
                        }
                        else if (item.GetComponent <Shape>().Type == "Coin")
                        {
                            isCoin = true;
                            numCoins++;
                        }
                        else if (item.GetComponent <Shape>().Type == "Goalie")
                        {
                            isGoalie = true;
                            numGoalies++;
                        }

                        shapes.Remove(item);
                        RemoveFromScene(item);
                    }

                    if (isBall)
                    {
                        DealDamage(numBalls);
                    }
                    if (isRef)
                    {
                        AddAttribute(0, numRefs, false);
                    }
                    if (isBlue)
                    {
                        AddAttribute(1, numBlues, false);
                    }
                    if (isGreen)
                    {
                        AddAttribute(2, numGreens, false);
                    }
                    if (isRed)
                    {
                        AddAttribute(3, numReds, false);
                    }
                    if (isCoin)
                    {
                        AddCoins(numCoins);
                    }
                    if (isGoalie)
                    {
                        RegainHp(numGoalies);
                    }

                    //get the columns that we had a collapse
                    var columns = totalMatches.Select(go => go.GetComponent <Shape>().Column).Distinct();

                    //collapse the ones gone
                    var collapsedCandyInfo = shapes.Collapse(columns);
                    //create new ones
                    var newCandyInfo = CreateNewCandyInSpecificColumns(columns);

                    int maxDistance = Mathf.Max(collapsedCandyInfo.MaxDistance, newCandyInfo.MaxDistance);

                    MoveAndAnimate(newCandyInfo.AlteredCandy, maxDistance);
                    MoveAndAnimate(collapsedCandyInfo.AlteredCandy, maxDistance);

                    //will wait for both of the above animations
                    yield return(new WaitForSeconds(Constants.MoveAnimationMinDuration * maxDistance));

                    //search if there are matches with the new/collapsed items
                    totalMatches = shapes.GetMatches(collapsedCandyInfo.AlteredCandy).
                                   Union(shapes.GetMatches(newCandyInfo.AlteredCandy)).Distinct();
                }
            }
        }

        yield return(new WaitForSeconds(1f));

        foreach (GameObject c in GameObject.FindGameObjectsWithTag(convertTo.GetComponent <Shape>().Type))
        {
            //get the matches via the helper methods
            MatchesInfo convertMatchesInfo = shapes.GetMatches(c);

            totalMatches = convertMatchesInfo.MatchedBlock;


            while (totalMatches.Count() >= Constants.MinimumMatches)
            {
                isBall   = false;
                isRef    = false;
                isBlue   = false;
                isGreen  = false;
                isRed    = false;
                isCoin   = false;
                isGoalie = false;

                numBalls   = 0;
                numRefs    = 0;
                numBlues   = 0;
                numGreens  = 0;
                numReds    = 0;
                numCoins   = 0;
                numGoalies = 0;

                soundManager.PlayCrincle();

                foreach (var item in totalMatches)
                {
                    if (item.GetComponent <Shape>().Type == "Ball")
                    {
                        isBall = true;
                        numBalls++;
                    }
                    else if (item.GetComponent <Shape>().Type == "Ref")
                    {
                        isRef = true;
                        numRefs++;
                    }
                    else if (item.GetComponent <Shape>().Type == "player_blue")
                    {
                        isBlue = true;
                        numBlues++;
                    }
                    else if (item.GetComponent <Shape>().Type == "player_green")
                    {
                        isGreen = true;
                        numGreens++;
                    }
                    else if (item.GetComponent <Shape>().Type == "player_red")
                    {
                        isRed = true;
                        numReds++;
                    }
                    else if (item.GetComponent <Shape>().Type == "Coin")
                    {
                        isCoin = true;
                        numCoins++;
                    }
                    else if (item.GetComponent <Shape>().Type == "Goalie")
                    {
                        isGoalie = true;
                        numGoalies++;
                    }

                    shapes.Remove(item);
                    RemoveFromScene(item);
                }

                if (isBall)
                {
                    DealDamage(numBalls);
                }
                if (isRef)
                {
                    AddAttribute(0, numRefs, false);
                }
                if (isBlue)
                {
                    AddAttribute(1, numBlues, false);
                }
                if (isGreen)
                {
                    AddAttribute(2, numGreens, false);
                }
                if (isRed)
                {
                    AddAttribute(3, numReds, false);
                }
                if (isCoin)
                {
                    AddCoins(numCoins);
                }
                if (isGoalie)
                {
                    RegainHp(numGoalies);
                }

                //get the columns that we had a collapse
                var columns = totalMatches.Select(go => go.GetComponent <Shape>().Column).Distinct();

                //collapse the ones gone
                var collapsedCandyInfo = shapes.Collapse(columns);
                //create new ones
                var newCandyInfo = CreateNewCandyInSpecificColumns(columns);

                int maxDistance = Mathf.Max(collapsedCandyInfo.MaxDistance, newCandyInfo.MaxDistance);

                MoveAndAnimate(newCandyInfo.AlteredCandy, maxDistance);
                MoveAndAnimate(collapsedCandyInfo.AlteredCandy, maxDistance);

                //will wait for both of the above animations
                yield return(new WaitForSeconds(Constants.MoveAnimationMinDuration * maxDistance));

                //search if there are matches with the new/collapsed items
                totalMatches = shapes.GetMatches(collapsedCandyInfo.AlteredCandy).
                               Union(shapes.GetMatches(newCandyInfo.AlteredCandy)).Distinct();
            }
        }

        StartCheckForPotentialMatches();
    }
示例#12
0
    /// <summary>
    /// IMPORTANT
    /// Do not delete this overload, as it is used dependently by the other GetMatches overload.
    /// </summary>
    /// <param name="go"></param>
    /// <returns></returns>
    public MatchesInfo GetMatches(GameObject go)
    {
        MatchesInfo matchesInfo = new MatchesInfo();

        var horizontalMatches = GetMatchesHorizontally(go);
        matchesInfo.AddObjectRange(horizontalMatches);

        var verticalMatches = GetMatchesVertically(go);
        matchesInfo.AddObjectRange(verticalMatches);

        return matchesInfo;
    }
示例#13
0
        private void _Search(List<string> pathToFile, string stringToSearch, string pathToSave = null)
        {
            logger.Info("Clean the return List of coincidences");
            FileInfo.Clear();
            logger.Info("initializing paramenter objects");

            object oMissing = System.Reflection.Missing.Value;
            object oTrue = true;
            object oFalse = false;

            try
            {
                logger.Info("instantiating word app");
                word = new Word.Application();
                logger.Info("instantiating document of word app");
                doc = new Word.Document();

                logger.Info("reading each files on path ={0}", pathToFile);
                foreach (string item in pathToFile)
                {
                    object fileName = item;
                    logger.Info("opening the file");
                    doc = word.Documents.Open(ref fileName, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oFalse, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
                    doc.Activate();
                    logger.Info("file opened and activates");

                    FileInfo fiIn = new FileInfo();
                    fiIn.FileName = item;
                    fiIn.FileNameOut = string.Format(@"{0}\{1}.pdf", pathToSave, Guid.NewGuid().ToString());

                    logger.Info("searching the text on each paragraphs");
                    foreach (Word.Paragraph Paragraph in doc.Paragraphs)
                    {
                        Word.Range rng = Paragraph.Range;

                        rng.Find.Text = stringToSearch.Trim();
                        rng.Find.ClearFormatting();
                        rng.Find.Forward = true;
                        rng.Find.Replacement.ClearFormatting();
                        rng.Find.Wrap = Word.WdFindWrap.wdFindStop;

                        rng.Find.Execute(
                                        ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                        ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                        ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);

                        while (rng.Find.Found)
                        {
                            rng.HighlightColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdDarkYellow;
                            rng.Font.ColorIndex = Microsoft.Office.Interop.Word.WdColorIndex.wdWhite;

                            MatchesInfo maIn = new MatchesInfo();
                            maIn.Page = (int)rng.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdActiveEndAdjustedPageNumber);
                            maIn.Line = (int)rng.get_Information(Microsoft.Office.Interop.Word.WdInformation.wdFirstCharacterLineNumber);

                            fiIn.MatchesList.Add(maIn);
                            logger.Info("text matching and highlight");

                            rng.Find.Execute(
                                        ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                        ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
                                        ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);
                        }
                    }

                    FileInfo.Add(fiIn);

                    if (!string.IsNullOrEmpty(pathToSave))
                    {
                        logger.Info("exporting the file");
                        doc.ExportAsFixedFormat(
                                fiIn.FileNameOut,
                                Word.WdExportFormat.wdExportFormatPDF,
                                OptimizeFor: Word.WdExportOptimizeFor.wdExportOptimizeForOnScreen,
                                BitmapMissingFonts: true, DocStructureTags: false);
                        logger.Info("file exported");
                    }

                    object saveOption = Word.WdSaveOptions.wdDoNotSaveChanges;
                    object originalFormat = Word.WdOriginalFormat.wdOriginalDocumentFormat;
                    object routeDocument = false;
                    ((Word._Document)doc).Close(ref saveOption, ref originalFormat, ref routeDocument);
                }
            }
            catch (Exception ex)
            {
                //TODO: Manipular errores;
                logger.Info("An exception has detected");
                logger.Error(ex);
                throw new Exception("");
                throw;
            }
            finally
            {
                ((Word._Application)word).Quit(ref oFalse, ref oMissing, ref oMissing);
            }
        }