//根据特殊糖果记录列表添加特殊糖果
    void addSpecial(List <SCandy> speciallist)
    {
        for (int index = 0; index < speciallist.Count; index++)
        {
            SCandy  temp_struct = speciallist[index];
            Vector3 vpos        = new Vector3(BVector.x + temp_struct.mCol * xOff, BVector.y + temp_struct.mRow * yOff, 0f);
            Candy   item        = NewCandy(temp_struct.mCol, temp_struct.mRow, vpos, temp_struct.mType, temp_struct.mIndex);

            setCandy(item);
        }
    }
    //检测是否会产生特殊糖果(inputlist 分组后的待消除糖果)
    List <SCandy> hasSpecialCandy(ref ArrayList inputlist)
    {
        List <SCandy> result = new List <SCandy>();

        for (int index = 0; index < inputlist.Count; index++)
        {
            //
            ArrayList temp_list    = inputlist[index] as ArrayList;
            int       random_index = UnityEngine.Random.Range(0, temp_list.Count);
            Candy     item         = temp_list[random_index] as Candy;
            //
            if (3 < temp_list.Count)
            {
                int sum_row = 0;
                int sum_col = 0;
                //
                for (int i = 0; i < temp_list.Count; i++)
                {
                    Candy temp_item = temp_list[i] as Candy;

                    if (item.mRow == temp_item.mRow)
                    {
                        sum_row++;
                    }
                    if (item.mCol == temp_item.mCol)
                    {
                        sum_col++;
                    }
                }
                //匹配组等于4
                if (4 == temp_list.Count)
                {
                    if (4 == sum_col)
                    {
                        SCandy temp_item = new SCandy(item.mCol, item.mRow, _TYPE.STREAKV, item.mIndex);
                        result.Add(temp_item);
                    }
                    else if (4 == sum_row)
                    {
                        SCandy temp_item = new SCandy(item.mCol, item.mRow, _TYPE.STREAKH, item.mIndex);
                        result.Add(temp_item);
                    }
                }
                else if (5 == temp_list.Count)
                {//匹配组等于5
                    if (5 == sum_col || 5 == sum_row)
                    {
                        SCandy temp_item = new SCandy(item.mCol, item.mRow, _TYPE.COLORFUL, item.mIndex);
                        result.Add(temp_item);
                    }
                    else
                    {
                        SCandy temp_item = new SCandy(item.mCol, item.mRow, _TYPE.PACKAGE, item.mIndex);
                        result.Add(temp_item);
                    }
                }
                else if (5 < temp_list.Count && sum_col == 4)
                {//匹配组大于5
                    SCandy temp_item = new SCandy(item.mCol, item.mRow, _TYPE.STREAKV, item.mIndex);
                    result.Add(temp_item);
                }
                else if (5 < temp_list.Count && sum_row == 4)
                {
                    SCandy temp_item = new SCandy(item.mCol, item.mRow, _TYPE.STREAKH, item.mIndex);
                    result.Add(temp_item);
                }
                else if (5 < temp_list.Count && (5 == sum_col || 5 == sum_row))
                {
                    SCandy temp_item = new SCandy(item.mCol, item.mRow, _TYPE.COLORFUL, item.mIndex);
                    result.Add(temp_item);
                }
            }
        }
        return(result);
    }
Example #3
0
    //检测是否会产生特殊糖果(inputlist 分组后的待消除糖果)
    List<SCandy> hasSpecialCandy(ref ArrayList inputlist)
    {
        List<SCandy> result = new List<SCandy>();
        for (int index = 0; index < inputlist.Count; index++)
        {
            //
            ArrayList temp_list = inputlist[index] as ArrayList;
            int random_index = UnityEngine.Random.Range(0, temp_list.Count);
            Candy item = temp_list[random_index] as Candy;
            //
            if (3 < temp_list.Count)
            {
                int sum_row = 0;
                int sum_col = 0;
                //
                for (int i = 0; i < temp_list.Count; i++)
                {
                    Candy temp_item = temp_list[i] as Candy;

                    if (item.mRow == temp_item.mRow)
                    {
                        sum_row++;
                    }
                    if (item.mCol == temp_item.mCol)
                    {
                        sum_col++;
                    }
                }
                //匹配组等于4
                if (4 == temp_list.Count)
                {
                    if (4 == sum_col)
                    {

                        SCandy temp_item = new SCandy(item.mCol, item.mRow, _TYPE.STREAKV, item.mIndex);
                        result.Add(temp_item);

                    }
                    else if (4 == sum_row)
                    {

                        SCandy temp_item = new SCandy(item.mCol, item.mRow, _TYPE.STREAKH, item.mIndex);
                        result.Add(temp_item);

                    }
                }
                else if (5 == temp_list.Count)
                {//匹配组等于5
                    if (5 == sum_col || 5 == sum_row)
                    {

                        SCandy temp_item = new SCandy(item.mCol, item.mRow, _TYPE.COLORFUL, item.mIndex);
                        result.Add(temp_item);

                    }
                    else
                    {

                        SCandy temp_item = new SCandy(item.mCol, item.mRow, _TYPE.PACKAGE, item.mIndex);
                        result.Add(temp_item);

                    }
                }
                else if (5 < temp_list.Count && sum_col == 4)
                {//匹配组大于5

                    SCandy temp_item = new SCandy(item.mCol, item.mRow, _TYPE.STREAKV, item.mIndex);
                    result.Add(temp_item);

                }
                else if (5 < temp_list.Count && sum_row == 4)
                {

                    SCandy temp_item = new SCandy(item.mCol, item.mRow, _TYPE.STREAKH, item.mIndex);
                    result.Add(temp_item);

                }
                else if (5 < temp_list.Count && (5 == sum_col || 5 == sum_row))
                {

                    SCandy temp_item = new SCandy(item.mCol, item.mRow, _TYPE.COLORFUL, item.mIndex);
                    result.Add(temp_item);

                }
            }
        }
        return result;
    }