示例#1
0
    public List <List <Item> > GetMatches(FindSeparating separating = FindSeparating.NONE, int matches = 3)
    {
        var newCombines = new List <List <Item> >();

        countedSquares = new Hashtable();
        countedSquares.Clear();
        for (var col = 0; col < fieldData.maxCols; col++)
        {
            for (var row = 0; row < fieldData.maxRows; row++)
            {
                if (GetSquare(col, row) != null)
                {
                    if (!countedSquares.ContainsValue(GetSquare(col, row).Item))
                    {
                        var newCombine = GetSquare(col, row).FindMatchesAround(separating, matches, countedSquares);
                        if (newCombine.Count >= matches)
                        {
                            newCombines.Add(newCombine);
                        }
                    }
                }
            }
        }
        return(newCombines);
    }
示例#2
0
文件: Square.cs 项目: fafara/3match
    Hashtable FindMoreMatches(int spr_COLOR, Hashtable countedSquares, FindSeparating separating, Hashtable countedSquaresGlobal = null)
    {
        bool globalCounter = true;

        if (countedSquaresGlobal == null)
        {
            globalCounter        = false;
            countedSquaresGlobal = new Hashtable();
        }
        ccc++;
        if (this.item == null)
        {
            return(countedSquares);
        }
        if (this.item.destroying)
        {
            return(countedSquares);
        }
        //    if (LevelManager.THIS.countedSquares.ContainsValue(this.item) && globalCounter) return countedSquares;
        if (this.item.color == spr_COLOR && !countedSquares.ContainsValue(this.item) && this.item.currentType != ItemsTypes.INGREDIENT)
        {
            if (LevelManager.THIS.onlyFalling && this.item.justCreatedItem)
            {
                countedSquares.Add(countedSquares.Count - 1, this.item);
            }
            else if (!LevelManager.THIS.onlyFalling)
            {
                countedSquares.Add(countedSquares.Count - 1, this.item);
            }
            else
            {
                return(countedSquares);
            }

            if (separating == FindSeparating.VERTICAL)
            {
                if (GetNeighborTop() != null)
                {
                    countedSquares = GetNeighborTop().FindMoreMatches(spr_COLOR, countedSquares, FindSeparating.VERTICAL);
                }
                if (GetNeighborBottom() != null)
                {
                    countedSquares = GetNeighborBottom().FindMoreMatches(spr_COLOR, countedSquares, FindSeparating.VERTICAL);
                }
            }
            else if (separating == FindSeparating.HORIZONTAL)
            {
                if (GetNeighborLeft() != null)
                {
                    countedSquares = GetNeighborLeft().FindMoreMatches(spr_COLOR, countedSquares, FindSeparating.HORIZONTAL);
                }
                if (GetNeighborRight() != null)
                {
                    countedSquares = GetNeighborRight().FindMoreMatches(spr_COLOR, countedSquares, FindSeparating.HORIZONTAL);
                }
            }
        }
        return(countedSquares);
    }
示例#3
0
文件: Square.cs 项目: fafara/3match
    public List <Item> FindMatchesAround(FindSeparating separating = FindSeparating.NONE, int matches = 3, Hashtable countedSquaresGlobal = null)
    {
        bool        globalCounter = true;
        List <Item> newList       = new List <Item>();

        if (countedSquaresGlobal == null)
        {
            globalCounter        = false;
            countedSquaresGlobal = new Hashtable();
        }
        Hashtable countedSquares = new Hashtable();

        countedSquares.Clear();
        if (this.item == null)
        {
            return(newList);
        }

        if (separating != FindSeparating.HORIZONTAL)
        {
            countedSquares = this.FindMoreMatches(this.item.color, countedSquares, FindSeparating.VERTICAL, countedSquaresGlobal);
        }

        foreach (DictionaryEntry de in countedSquares)
        {
            LevelManager.THIS.countedSquares.Add(LevelManager.THIS.countedSquares.Count - 1, de.Value);
        }

        if (countedSquares.Count < matches)
        {
            countedSquares.Clear();
        }

        if (separating != FindSeparating.VERTICAL)
        {
            countedSquares = this.FindMoreMatches(this.item.color, countedSquares, FindSeparating.HORIZONTAL, countedSquaresGlobal);
        }

        foreach (DictionaryEntry de in countedSquares)
        {
            LevelManager.THIS.countedSquares.Add(LevelManager.THIS.countedSquares.Count - 1, de.Value);
        }

        if (countedSquares.Count < matches)
        {
            countedSquares.Clear();
        }

        foreach (DictionaryEntry de in countedSquares)
        {
            newList.Add((Item)de.Value);
        }
        // print(countedSquares.Count);
        return(newList);
    }
示例#4
0
    public List <Item> FindMatchesAround(FindSeparating separating = FindSeparating.NONE, int matches = 3, Hashtable countedSquaresGlobal = null)
    {
        var globalCounter = true;
        var newList       = new List <Item>();

        if (countedSquaresGlobal == null)
        {
            globalCounter        = false;
            countedSquaresGlobal = new Hashtable();
        }
        var countedSquares = new Hashtable();

        countedSquares.Clear();
        if (Item == null)
        {
            return(newList);
        }
        if (!Item.Combinable)
        {
            return(newList);
        }
        //		if (separating != FindSeparating.HORIZONTAL)
        //		{
        countedSquares = FindMoreMatches(Item.color, countedSquares, FindSeparating.VERTICAL, countedSquaresGlobal);
        //		}

        foreach (DictionaryEntry de in countedSquares)
        {
            field.countedSquares.Add(field.countedSquares.Count - 1, de.Value);
        }

        foreach (DictionaryEntry de in countedSquares)
        {
            field.countedSquares.Add(field.countedSquares.Count - 1, de.Value);
        }

        if (countedSquares.Count < matches)
        {
            countedSquares.Clear();
        }

        foreach (DictionaryEntry de in countedSquares)
        {
            newList.Add((Item)de.Value);
        }
        // print(countedSquares.Count);
        return(newList.Distinct().ToList());
    }