Ejemplo n.º 1
0
    public void CheckMatches()
    {
        List <List <GridObject> > matches = Matches();

        if (matches.Count() > 0)
        {
            audio.PlayOneShot(matchSound);
            Debug.Log("checking matches");
            // Add the scores
            foreach (List <GridObject> matchSequence in matches)
            {
                score.AddForMatch(matchSequence);
            }
            // Then destroy the objects
            foreach (List <GridObject> matchSequence in matches)
            {
                foreach (GridObject gridObject in matchSequence)
                {
                    grid.RemoveObject(gridObject);
                }
            }
            grid.OnGridObjectsDestroyed();
        }
        else if (!PossibleMatches().HasMatches())
        {
            Debug.Log("no matches");
            audio.PlayOneShot(noMovesSound);
            grid.ResetBoard();
        }
        else
        {
            score.matchesCombo = 0;
        }
        cachedMatches         = null;
        CachedPossibleMatches = null;
        score.EndSequence();

        //PossibleMatches ();
    }