コード例 #1
0
    /// <summary>
    /// новые Конфеты
    /// </summary>
    /// <param name="colls"></param>
    /// <returns></returns>
    private UpdateAfterMatch GetNeighbourProp(IEnumerable <int> colls)
    {
        UpdateAfterMatch afterMatch = new UpdateAfterMatch();

        foreach (int coll in colls)
        {
            var emptyGems = GetArrays.NullGemsonc(coll);
            foreach (var g in emptyGems)
            {
                if (IsNulls(g.row, coll) == false)//
                {
                    var pref = GetCandyPrefab[Random.Range(0, GetCandyPrefab.Length)];
                    if ((int)levelsApps.ltype == 1)
                    {
                        int[] randomplus5sec = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
                        int   plus5sec       = randomplus5sec[Random.Range(0, randomplus5sec.Length)];
                        if ((int)levelsApps.ltype == 1 && plus5sec == coll)
                        {
                            pref = GetCandieSecons[Random.Range(0, GetCandieSecons.Length)];
                        }
                    }
                    var initgem = ((GameObject)Instantiate(pref.gameObject, new Vector3(visibleSize[coll].x, visibleSize[coll].y, -0.1f), Quaternion.identity)).GetComponent <HitCandy>();
                    initgem.transform.SetParent(GetArrays.transform);
                    g.OnInit(initgem);
                    if (GetArrays.SizeY - g.row > afterMatch.MaxDistance)
                    {
                        afterMatch.MaxDistance = GetArrays.SizeY - g.row;
                    }
                    afterMatch.AddGemms(g);
                }
                if (IsNulls(g.row, coll) == true)                                    //
                {
                    if (GetArrays.gems[g.row, coll].hitGem.type == "ingredient" + 0) //
                    {
                        levelsApps.ingCtar[0] -= 1;
                    }
                    if (GetArrays.gems[g.row, coll].hitGem.type == "ingredient" + 1)//
                    {
                        levelsApps.ingCtar[0] -= 1;
                    }
                    //Destroy(GetArrays.gems[g.y, coll].hitGem.gameObject);
                }
            }
        }
        return(afterMatch);
    }
コード例 #2
0
    /// <summary>
    /// Collapse
    /// </summary>
    /// <param name="colum"></param>
    /// <returns></returns>
    public UpdateAfterMatch UpdateAfter(IEnumerable <int> colum)
    {
        UpdateAfterMatch afterMatch = new UpdateAfterMatch();

        foreach (var c in colum)
        {
            for (int row = 0; row < SizeY - 1; row++)
            {
                if (gems[row, c].hitGem == null && IsNulls(row, c) == false)
                {
                    for (int row2 = row + 1; row2 < SizeY; row2++)
                    {
                        if (!gems[row2, c].INull && IsNulls(row2, c) == false)
                        {
                            Gem gem1 = gems[row, c];
                            Gem gem2 = gems[row2, c];
                            gem1.OnInit(gem2.hitGem);
                            gem2.Nil();
                            afterMatch.MaxDistance = Mathf.Max(row2 - row, afterMatch.MaxDistance);
                            afterMatch.AddGemms(gem1);
                            if (IsNulls(row, c) == true || levelsManager2.blocksp[row * levelsManager2.MaxX + c].types == 0)
                            {
                                Destroy(gems[row, c].hitGem.gameObject);
                            }
                            if (IsNulls(row2, c) == true || levelsManager2.blocksp[row2 * levelsManager2.MaxX + c].types == 0)
                            {
                                Destroy(gems[row2, c].hitGem.gameObject);
                            }
                            break;
                        }
                    }
                }
            }
        }

        return(afterMatch);
    }