コード例 #1
0
    /// <summary>
    /// создать бонус
    /// </summary>
    /// <param name="bgem"></param>
    /// <param name="type"></param>
    public void CreateBonus(Block bgem, int rw, int cl, string type)
    {
        float    xc          = levelsApps.blckWH();
        float    yr          = levelsApps.blckWH();
        HitCandy hitCandynew = null;

        if (type == "swirl")
        {
            hitCandynew = swirlPrefab;
        }
        else
        {
            for (int i = 0; i < GetBonusPrefab.Length; i++)
            {
                if (GetBonusPrefab[i].type == type)
                {
                    hitCandynew = GetBonusPrefab[i];
                }
            }
        }
        Vector2  vectorgem = levelsApps.vector2position + new Vector2(cl * xc, rw * yr);
        HitCandy bonuses   = ((GameObject)Instantiate(hitCandynew.gameObject, new Vector3(vectorgem.x, vectorgem.y, -0.1f), Quaternion.identity)).GetComponent <HitCandy>();

        bonuses.transform.SetParent(GetArrays.transform);
        //GetArrays[bgem.row, bgem.col].OnInit(bonuses);
        //GetArrays.gems[bgem.row, bgem.col] = bonuses.GetGem;
        OpenAppLevel.THIS.blocksp[rw * OpenAppLevel.THIS.MaxX + cl].OnInit(bonuses);
        OpenAppLevel.THIS.blocksp[rw * OpenAppLevel.THIS.MaxX + cl] = bonuses.GetBlock;
        bonuses.GetBlock.bonus = 1;
        bonuses.isBonus        = true;
        if (type == "swirl")
        {
            bonuses.type = type; bonuses.isSwirl = true; bonuses.isBonus = false;
        }
    }
コード例 #2
0
    /// <summary>
    /// создать бонус
    /// </summary>
    /// <param name="bgem"></param>
    /// <param name="type"></param>
    public void CreateBonus(Gem bgem, string type)
    {
        float    xc          = levelsApps.blckWH();
        float    yr          = levelsApps.blckWH();
        HitCandy hitCandynew = null;

        if (type == "swirl")
        {
            hitCandynew = swirlPrefab;
        }
        else
        {
            for (int i = 0; i < GetBonusPrefab.Length; i++)
            {
                if (GetBonusPrefab[i].type == type)
                {
                    hitCandynew = GetBonusPrefab[i];
                }
            }
        }
        Vector2  vectorgem = levelsApps.vector2position + (new Vector2(bgem.x * xc, bgem.y * yr));
        HitCandy bonuses   = ((GameObject)Instantiate(hitCandynew.gameObject, new Vector3(vectorgem.x, vectorgem.y, -0.1f), Quaternion.identity)).GetComponent <HitCandy>();

        bonuses.transform.SetParent(GetArrays.transform);
        GetArrays[bgem.y, bgem.x].OnInit(bonuses);
        GetArrays.gems[bgem.y, bgem.x] = bonuses.GetGem;
        bonuses.GetGem.bonus           = 1;
        bonuses.isBonus = true;
        if (type == "swirl")
        {
            bonuses.type = type; bonuses.isSwirl = true; bonuses.isBonus = false;
        }
    }
コード例 #3
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="row"></param>
    /// <param name="c"></param>
    /// <param name="hgem"></param>
    public void CreateGem(int row, int c, HitCandy hgem)
    {
        if (GetArrays[row, c] == null)
        {
            return;
        }
        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 == c)
        {
            hgem = GetCandieSecons[Random.Range(0, GetCandieSecons.Length)];
        }
        float    xc        = levelsApps.blckWH();
        float    yr        = levelsApps.blckWH();
        Vector2  vectorgem = levelsApps.vector2position + (new Vector2(c * xc, row * yr));
        HitCandy gemit     = ((GameObject)Instantiate(hgem.gameObject, new Vector3(vectorgem.x, vectorgem.y, -0.1f), Quaternion.identity)).GetComponent <HitCandy>();

        gemit.transform.SetParent(GetArrays.transform);
        GetArrays[row, c].OnInit(gemit);
        OpenAppLevel.THIS.blocksp[row * OpenAppLevel.THIS.MaxX + c].candy = gemit;
        OpenAppLevel.THIS.blocksp[row * OpenAppLevel.THIS.MaxX + c].OnInit(gemit);
        if (IsNulls(row, c) == true)
        {
            Destroy(gemit.gameObject);
        }
    }
コード例 #4
0
    public void OnSwapping(Gem gem1, Gem gem2)
    {
        GetGem1 = gem1;
        GetGem2 = gem2;

        HitCandy hitGem = gem1.hitGem;

        gem1.OnInit(gem2.hitGem);
        gem2.OnInit(hitGem);
    }
コード例 #5
0
    // Update is called once per frame
    void Update()
    {
        GetTextMove.text = string.Format("{0}", movecount);
        if (movecount != limitMove)
        {
            GetTextMove.gameObject.SetActive(true);//
            switch (state)
            {
            case 0:
                if (levelsApps.modeLvl == 2)
                {
                    StartCoroutine(IngredientScale());
                }
                if (Input.GetMouseButtonDown(0))
                {
                    var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector3.zero);
                    if (hit.collider != null)
                    {
                        GetHitGem = hit.collider.GetComponent <HitCandy>();
                        state     = 1;
                        if ((uint)levelsApps.ltype == 1)
                        {
                            //levelsApps.GetPause();
                        }
                    }
                }
                break;

            case 1:
                if (Input.GetMouseButtonUp(0))
                {
                    var hits = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector3.zero);
                    if (hits.collider != null && GetHitGem != hits.collider.gameObject)
                    {
                        HitCandy GetHitGem2 = hits.collider.gameObject.GetComponent <HitCandy>();
                        if (!((GetHitGem.GetGem.x == GetHitGem2.GetGem.x || GetHitGem.GetGem.y == GetHitGem.GetGem.y) && (Mathf.Abs(GetHitGem.GetGem.x - GetHitGem2.GetGem.x) <= 1 && Mathf.Abs(GetHitGem.GetGem.y - GetHitGem2.GetGem.y) <= 1)))
                        {
                            state = 0;
                        }
                        else
                        {
                            state = 2;
                            if (movecount == 1)
                            {
                                Ending = 1;
                            }
                            movecount -= 1;
                            StartCoroutine(TryMatch(hits));
                        }
                    }
                }
                break;
            }
        }
    }
コード例 #6
0
    /// <summary>
    /// начало
    /// </summary>
    private void Gems()
    {
        float xc = levelsApps.blckWH(); //
        float yr = levelsApps.blckWH(); //

        for (int row = 0; row < GetArrays.SizeY; row++)
        {
            for (int col = 0; col < GetArrays.SizeX; col++)
            {
                if (GetArrays[row, col].INull == false)
                {
                    Destroy(obj: GetArrays[row, col].hitGem.gameObject);
                }
            }
        }
        for (int row = 0; row < SizeY; row++)
        {
            for (int col = 0; col < SizeX; col++)
            {
                GetArrays.gems[row, col].Nil();
            }
        }
        int g = SizeX;

        visibleSize = new Vector2[g];

        for (int row = 0; row < SizeY; row++)
        {
            for (int col = 0; col < SizeX; col++)
            {
                HitCandy hitCandy = GetCandyPrefab[Random.Range(0, GetCandyPrefab.Length)];
                while (col >= 2 && GetArrays[row, col - 1].hitGem.isequal(hitCandy) && GetArrays[row, col - 2].hitGem.isequal(hitCandy))//&& levelsManager.squaresArray[(row) * levelsManager.maxCols + (col-1)].types != SquareTypes.NONE&& levelsManager.squaresArray[(row) * levelsManager.maxCols + (col-1)].types != SquareTypes.NONE)
                {
                    hitCandy = GetCandyPrefab[Random.Range(0, GetCandyPrefab.Length)];
                }
                while (row >= 2 && GetArrays[row - 1, col].hitGem.isequal(hitCandy) && GetArrays[row - 2, col].hitGem.isequal(hitCandy))//&& levelsManager.squaresArray[(row - 1) * levelsManager.maxCols + col].types != SquareTypes.NONE && levelsManager.squaresArray[(row-2)*levelsManager.maxCols+col].types!=SquareTypes.NONE)
                {
                    hitCandy = GetCandyPrefab[Random.Range(0, GetCandyPrefab.Length)];
                }
                CreateGem(row, col, hitCandy);
            }
        }

        for (int i = 0; i < SizeX; i++)
        {
            visibleSize[i] = levelsApps.vector2position + new Vector2(i * xc, SizeY * yr); //new Vector2(-2.37f, -4.27f) + new Vector2(i * 0.7f, SizeY * 0.7f);
        }
        if (levelsApps.modeLvl != 2)
        {
            LoadHelp();
        }
    }
コード例 #7
0
 private void Awake()
 {
     THIS               = this;
     GetHitNext         = GetCandyPrefab[Random.Range(0, GetCandyPrefab.Length)];
     GetHitGem          = GetHitNext;
     BubleCursor.sprite = GetHitNext.GetComponent <SpriteRenderer>().sprite;
     //BubleCursor.GetComponent<HitCandy>() = GetHitGem;
     bubble2    = GetHitGem;
     GetHitNext = GetCandyPrefab[Random.Range(0, GetCandyPrefab.Length)];
     //if (GetHitGem != null)
     //{
     //    HitsCand.Add(GetHitGem);
     //}
     //if (bubble2 != null)
     //{
     //    HitsCand.Add(bubble2);
     //}
 }
コード例 #8
0
    /// <summary>
    /// уночтожить совпадения
    /// </summary>
    /// <param name="hitmatchs"></param>
    public void ScaleMatch(HitCandy hitmatchs)
    {
        if ((int)levelsApps.ltype == 1 && hitmatchs.seconds != 0)
        {
            levelsApps.Limit += hitmatchs.seconds;
        }
        if (levelsApps.modeLvl == 1)
        {
            string[] CollectItemsfromcolor = { "", "red", "purple", "blue1", "blue2" };
            for (int i = 0; i < CollectItemsfromcolor.Count(); i++)
            {
                if (hitmatchs.type == CollectItemsfromcolor[i])
                {
                    if (i == (int)levelsApps.collectItems[0])
                    {
                        if (levelsApps.ingCtar[0] > 0)
                        {
                            levelsApps.ingCtar[0] -= 1;
                        }
                    }
                    if (i == (int)levelsApps.collectItems[1])
                    {
                        if (levelsApps.ingCtar[1] > 0)
                        {
                            levelsApps.ingCtar[1] -= 1;
                        }
                    }
                }
            }
        }

        levelsApps.printScores += 10;

        if (levelsApps.blocksp[hitmatchs.GetGem.y * levelsApps.MaxX + hitmatchs.GetGem.x].modelvlsquare == 3)
        {
            levelsApps.NotColorSquare(hitmatchs.GetGem.x, hitmatchs.GetGem.y, sprite12);
            levelsApps.blockscount -= 1;
        }
        if (levelsApps.blocksp[hitmatchs.GetGem.y * levelsApps.MaxX + hitmatchs.GetGem.x].types != 0)
        {
            hitmatchs.GetGem.Nil();
            Destroy(hitmatchs.gameObject);
        }
    }
コード例 #9
0
    public void Scale2Match(HitCandy hitmatchs)
    {
        if ((int)levelsApps.ltype == 1 && hitmatchs.seconds != 0)
        {
            levelsApps.Limit += hitmatchs.seconds;
        }
        if (levelsApps.modeLvl == 1)
        {
            string[] CollectItemsfromcolor = { "", "red", "purple", "blue1", "blue2" };
            for (int i = 0; i < CollectItemsfromcolor.Count(); i++)
            {
                if (hitmatchs.type == CollectItemsfromcolor[i])
                {
                    if (i == (int)levelsApps.collectItems[0])
                    {
                        if (levelsApps.ingCtar[0] > 0)
                        {
                            levelsApps.ingCtar[0] -= 1;
                        }
                    }
                    if (i == (int)levelsApps.collectItems[1])
                    {
                        if (levelsApps.ingCtar[1] > 0)
                        {
                            levelsApps.ingCtar[1] -= 1;
                        }
                    }
                }
            }
        }

        levelsApps.printScores += 10;
        //if (hitmatchs.GetBlock.candy != null)
        //{
        //    hitmatchs.GetBlock.Nil();
        //}
        hitmatchs.GetBlock.Nil();
        Destroy(hitmatchs.gameObject);
    }
コード例 #10
0
    public void MovedGem(int row, int c, HitCandy hgem)
    {
        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 == c)
        {
            hgem = GetCandieSecons[Random.Range(0, GetCandieSecons.Length)];
        }
        float   xc        = levelsApps.blckWH();
        float   yr        = levelsApps.blckWH();
        Vector2 vectorgem = levelsApps.vector2position + (new Vector2(c * xc, row * yr));

        hgem.gameObject.transform.position = new Vector3(vectorgem.x, vectorgem.y, -0.1f);
        hgem.transform.SetParent(GetArrays.transform);
        GetArrays[row, c].OnInit(hgem);
        OpenAppLevel.THIS.blocksp[row * OpenAppLevel.THIS.MaxX + c].candy = hgem;
        OpenAppLevel.THIS.blocksp[row * OpenAppLevel.THIS.MaxX + c].OnInit(hgem);
        if (IsNulls(row, c) == true)
        {
            Destroy(hgem.gameObject);
        }
    }
コード例 #11
0
    /// <summary>
    /// Начинаем собирать совпадения
    /// </summary>
    /// <param name="raycast2"></param>
    /// <returns></returns>
    IEnumerator TryMatch(RaycastHit2D raycast2)
    {
        HitCandy GetHitGem2 = bubble2;

        if (GetHitGem.type == "swirl" && GetHitGem2.type != "ingredient" + 0 && GetHitGem2.type != "ingredient" + 1)
        {
            GetHitGem.type = GetHitGem2.type;
        }
        GetHitColor = GetHitColors[Random.Range(0, GetHitColors.Length)];
        if (GetHitGem2.type == "swirl" && GetHitGem.type != "ingredient" + 0 && GetHitGem.type != "ingredient" + 1)
        {
            GetHitGem2.type = GetHitGem.type;
        }
        Block blockpr = null;

        if (CurrentBlk != null)
        {
            blockpr = CurrentBlk;
        }
        else
        {
            blockpr = GetHitGem.GetBlock;
        }
        var GetHitGemNeigbours  = GetArrays.GetProp(blockpr, blockpr.row, blockpr.col);
        var GetHitGemNeigbours2 = GetArrays.GetProp(OpenAppLevel.THIS.blocksp[currentrow * OpenAppLevel.THIS.MaxX + currentcol], currentrow, currentcol);
        var matchs = GetHitGemNeigbours.GetGems.Union(GetHitGemNeigbours2.GetGems).Distinct();

        movecount -= 1;
        if (matchs.Count() < 3)
        {
            //GetHitGem.transform.TweenPosition(0.2f, GetHitGem2.transform.position);
            //GetHitGem2.transform.TweenPosition(0.2f, GetHitGem.transform.position);
            yield return(new WaitForSeconds(0.2f));

            GetArrays.Lastsp();

            if (Ending == 1)
            {
                Ending = 0;
            }
        }
        string typebonus      = "";
        Block  bonusGem       = null;
        bool   addsquareBonus = false;
        bool   addswirlBonus  = matchs.Count() == 5 && GetHitGemNeigbours.bt == 1 || GetHitGemNeigbours2.bt == 1;
        bool   addBonus       = matchs.Count() >= 4 && GetHitGemNeigbours.bt == 1 || GetHitGemNeigbours2.bt == 1;

        if (addBonus)
        {
            var sameTypeGem = GetHitGemNeigbours.gemms.Count() > 0 ? GetHitGem : GetHitGem2;
            bonusGem = sameTypeGem.GetBlock;
            if (matchs.Count() == 5)
            {
                //sameTypeGem.type = "swirl";
            }
            typebonus = sameTypeGem.type;
            OpenAppLevel.THIS.StripeGameCount += 1;
        }
        while (matchs.Count() >= 2)
        {
            NeighbourProp neighbour = new NeighbourProp();
            foreach (var i in matchs)
            {
                if (rightMouseButtonDown)
                {
                    OpenAppLevel.THIS.printScores += 10;
                    //GetArrays.gems[i.row, i.col] = new Gem(i.row, i.col);
                    //GetArrays.gems[i.row, i.col].Nil();
                    CreateSquaresBlocks(i.col, i.row, CurrentBlk);
                    if (i.candy != null)
                    {
                        Destroy(i.candy.gameObject);
                    }
                    neighbour = GetArrays.GetProp(i, i.row, i.col);
                    //GetHitGem.transform.SetParent(GetHitGem.GetBlock.transform);

                    GetBlockMove = GetHitGem.GetBlock;
                    matchs       = neighbour.GetGems;
                }
                else
                {
                    neighbour = GetArrays.GetProp(i, i.row, i.col);
                    CreateSquaresBlocks(i.col, i.row, CurrentBlk);

                    matchs = neighbour.GetGems;
                }
            }
            //ScaleMatch()
            if (addBonus)
            {
                CreateBonus(GetHitGem.GetBlock, currentrow, currentcol, typebonus);
            }
            addBonus = false;

            //var bottom = matchs.Select(gem => gem.col).Distinct();
            //var updateafterMatch = GetArrays.UpdateAfter(bottom);
            //var newSpawn = GetNeighbourProp(bottom);
            //int maxDistance = Mathf.Max(updateafterMatch.MaxDistance, newSpawn.MaxDistance);
            //Moved(maxDistance, newSpawn.GetGems);
            //Moved(updateafterMatch.MaxDistance, updateafterMatch.GetGems);
            if (neighbour.GetGems != null)
            {
                neighbour.MaxDistance = 2;
                yield return(new WaitForSeconds(0.05f * neighbour.MaxDistance));

                matchs = neighbour.GetGems;
                if (rightMouseButtonDown)
                {
                    currentHitList = matchs;
                }
            }
            else
            {
                yield return(new WaitForSeconds(0.05f));
            }
            // * Mathf.Max(updateafterMatch.MaxDistance, newSpawn.MaxDistance));
            //matchs = GetArrays.GetNeighbours(newSpawn.GetGems).Union(GetArrays.GetNeighbours(updateafterMatch.GetGems)).Distinct();
            //matchs = GetArrays.GetNeighbours(updateafterMatch.GetGems).Distinct();
        }
        //GetHitGem = GetCandyPrefab[Random.Range(0, GetCandyPrefab.Length)];
        //bubble2 = GetHitGem;
        //BubleCursor.sprite = GetHitGem.GetComponent<SpriteRenderer>().sprite;
        if (Ending == 1)
        {
            levelsApps.LoadLB();
            Ending = 2;
        }
        for (int i = 0; i < bug.Length; i++)
        {
            bug[i].transform.position = new Vector3(0, -123, 0);
        }
        if (rightMouseButtonDown)
        {
            state = 1;
        }
        else
        {
            state = 0;
        }
        //levelsApps.GetPause();
    }
コード例 #12
0
    /// <summary>
    /// Начинаем собирать совпадения
    /// </summary>
    /// <param name="raycast2"></param>
    /// <returns></returns>
    IEnumerator TryMatch(RaycastHit2D raycast2)
    {
        HitCandy GetHitGem2 = raycast2.collider.gameObject.GetComponent <HitCandy>();

        if (GetHitGem.type == "swirl" && GetHitGem2.type != "ingredient" + 0 && GetHitGem2.type != "ingredient" + 1)
        {
            GetHitGem.type = GetHitGem2.type;
        }
        if (GetHitGem2.type == "swirl" && GetHitGem.type != "ingredient" + 0 && GetHitGem.type != "ingredient" + 1)
        {
            GetHitGem2.type = GetHitGem.type;
        }
        GetArrays.OnSwapping(GetHitGem.GetGem, GetHitGem2.GetGem);
        GetHitGem.transform.TweenPosition(0.2f, GetHitGem2.transform.position);
        GetHitGem2.transform.TweenPosition(0.2f, GetHitGem.transform.position);
        yield return(new WaitForSeconds(0.2f));

        var GetHitGemNeigbours  = GetArrays.GetProp(GetHitGem.GetGem);
        var GetHitGemNeigbours2 = GetArrays.GetProp(GetHitGem2.GetGem);
        var matchs = GetHitGemNeigbours.GetGems.Union(GetHitGemNeigbours2.GetGems).Distinct();

        if (matchs.Count() < 3)
        {
            GetHitGem.transform.TweenPosition(0.2f, GetHitGem2.transform.position);
            GetHitGem2.transform.TweenPosition(0.2f, GetHitGem.transform.position);
            yield return(new WaitForSeconds(0.2f));

            GetArrays.Lastsp();
            movecount += 1;
            if (Ending == 1)
            {
                Ending = 0;
            }
        }
        string typebonus      = "";
        Gem    bonusGem       = null;
        bool   addsquareBonus = false;
        bool   addswirlBonus  = matchs.Count() == 5 && GetHitGemNeigbours.bt == 1 || GetHitGemNeigbours2.bt == 1;
        bool   addBonus       = matchs.Count() >= 4 && GetHitGemNeigbours.bt == 1 || GetHitGemNeigbours2.bt == 1;

        if (addBonus)
        {
            var sameTypeGem = GetHitGemNeigbours.gemms.Count() > 0 ? GetHitGem : GetHitGem2;
            bonusGem = sameTypeGem.GetGem;
            if (matchs.Count() == 5)
            {
                sameTypeGem.type = "swirl";
            }
            typebonus = sameTypeGem.type;
            OpenAppLevel.THIS.StripeGameCount += 1;
        }
        while (matchs.Count() >= 3)
        {
            foreach (var i in matchs)
            {
                ScaleMatch(i.hitGem);
            }
            //ScaleMatch()
            if (addBonus)
            {
                CreateBonus(bonusGem, typebonus);
            }
            addBonus = false;
            var bottom           = matchs.Select(gem => gem.x).Distinct();
            var updateafterMatch = GetArrays.UpdateAfter(bottom);
            var newSpawn         = GetNeighbourProp(bottom);
            int maxDistance      = Mathf.Max(updateafterMatch.MaxDistance, newSpawn.MaxDistance);
            Moved(maxDistance, newSpawn.GetGems);
            Moved(maxDistance, updateafterMatch.GetGems);
            yield return(new WaitForSeconds(0.05f * Mathf.Max(updateafterMatch.MaxDistance, newSpawn.MaxDistance)));

            matchs = GetArrays.GetNeighbours(newSpawn.GetGems).Union(GetArrays.GetNeighbours(updateafterMatch.GetGems)).Distinct();
        }
        if (Ending == 1)
        {
            levelsApps.LoadLB();
            Ending = 2;
        }
        for (int i = 0; i < bug.Length; i++)
        {
            bug[i].transform.position = new Vector3(0, -123, 0);
        }
        state = 0;
        //levelsApps.GetPause();
    }
コード例 #13
0
    /// <summary>
    /// начало
    /// </summary>
    private void Gems()
    {
        BlockParents.Clear();
        MoveParents.Clear();
        GetHitGem          = GetHitNext;
        GetHitNext         = GetCandyPrefab[Random.Range(0, GetCandyPrefab.Length)];
        BubleCursor.sprite = GetHitGem.GetComponent <SpriteRenderer>().sprite;
        //BubleCursor.gameObject.GetComponent<HitCandy>() = GetHitGem;
        bubble  = GetHitGem;
        bubble2 = GetHitGem;
        float xc = levelsApps.blckWH(); //
        float yr = levelsApps.blckWH(); //

        blocksquare = new Block[SizeX * SizeY];
        for (int row = 0; row < GetArrays.SizeY; row++)
        {
            for (int col = 0; col < GetArrays.SizeX; col++)
            {
                if (GetArrays[row, col].INull == false)
                {
                    Destroy(obj: GetArrays[row, col].hitGem.gameObject);
                }
            }
        }
        for (int rw = 0; rw < OpenAppLevel.THIS.MaxY; rw++)
        {
            for (int cl = 0; cl < OpenAppLevel.THIS.MaxX; cl++)
            {
            }
        }
        for (int row = 0; row < OpenAppLevel.THIS.MaxY; row++)
        {
            for (int col = 0; col < OpenAppLevel.THIS.MaxX; col++)
            {
                GetArrays.gems[row, col] = new Gem(row, col);
                GetArrays.gems[row, col].Nil();
            }
        }
        int g = SizeX;

        visibleSize = new Vector2[g];

        for (int row = 0; row < SizeY; row++)
        {
            for (int col = 0; col < SizeX; col++)
            {
                HitCandy hitCandy = GetCandyPrefab[Random.Range(0, GetCandyPrefab.Length)];
                //while (col >= 2 && GetArrays[row, col - 1].hitGem.isequal(hitCandy) && GetArrays[row, col - 2].hitGem.isequal(hitCandy))//&& levelsManager.squaresArray[(row) * levelsManager.maxCols + (col-1)].types != SquareTypes.NONE&& levelsManager.squaresArray[(row) * levelsManager.maxCols + (col-1)].types != SquareTypes.NONE)
                //{
                hitCandy = GetCandyPrefab[Random.Range(0, GetCandyPrefab.Length)];
                //}
                //while (row >= 2 && GetArrays[row - 1, col].hitGem.isequal(hitCandy) && GetArrays[row - 2, col].hitGem.isequal(hitCandy))//&& levelsManager.squaresArray[(row - 1) * levelsManager.maxCols + col].types != SquareTypes.NONE && levelsManager.squaresArray[(row-2)*levelsManager.maxCols+col].types!=SquareTypes.NONE)
                //{
                //hitCandy = GetCandyPrefab[Random.Range(0, GetCandyPrefab.Length)];
                //}
                //CreateSquaresBlocks(col, row);
                CreateGem(row, col, hitCandy);
            }
        }

        for (int i = 0; i < SizeX; i++)
        {
            visibleSize[i] = levelsApps.vector2position + new Vector2(i * xc, SizeY * yr); //new Vector2(-2.37f, -4.27f) + new Vector2(i * 0.7f, SizeY * 0.7f);
        }
        if (levelsApps.modeLvl != 2)
        {
            LoadHelp();
        }
    }
コード例 #14
0
 public void addCandies(HitCandy candy)
 {
     CurrenthitCandies.Add(candy);
 }
コード例 #15
0
    // Update is called once per frame
    void Update()
    {
        BubleCursor.GetComponent <RectTransform>().anchoredPosition = Input.mousePosition;
        GetTextMove.text = string.Format("{0}", movecount);
        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (bubbleplus >= 4)
            {
                bubbleplus = 0;
            }
            else
            {
                bubbleplus += 1;
            }
        }
        //BubleCursor.sprite = GetHitGem.GetComponent<SpriteRenderer>().sprite;
        if (Input.GetMouseButtonDown(0))
        {
            var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector3.zero);
            if (hit.collider != null && state == 1)
            {
                BlockParents.Remove(GetBlockMove);
                CurrentBlk = hit.collider.GetComponent <Block>();
                Destroy(GetBlockMove.gameObject);
                StartCoroutine(GetEnumerator());
            }
        }
        if (Input.GetMouseButtonDown(1))
        {
            var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector3.zero);
            //print(hit.collider.GetComponent<Block>().types);
            if (hit.collider != null && state == 1)
            {
                //StopCoroutine(TryMatch(hit));
                CurrentBlk = hit.collider.GetComponent <Block>();

                //GetHitGem = GetCandyPrefab[Random.Range(0, GetCandyPrefab.Length)];
                //BubleCursor.sprite = GetHitGem.GetComponent<SpriteRenderer>().sprite;
                ////BubleCursor.GetComponent<HitCandy>() = GetHitGem;
                //bubble2 = GetHitGem;
                if (CurrentBlk != null && GetBlockMove != null)
                {
                    if (CurrentBlk.types == 2)
                    {
                        GetBlockMove.transform.position = CurrentBlk.transform.position;
                        //var createload = Instantiate(GetBlockMove.gameObject, CurrentBlk.transform.position, Quaternion.identity);
                        //GetHitGem = GetCandyPrefab[Random.Range(0, GetCandyPrefab.Length)];
                        //BubleCursor.sprite = GetHitGem.GetComponent<SpriteRenderer>().sprite;
                        ////BubleCursor.GetComponent<HitCandy>() = GetHitGem;
                        //bubble2 = GetHitGem;
                        GetBlockMove = null;
                        //MoveParents.Clear();

                        StartCoroutine(GetEnumerator());
                    }
                }
            }
        }
        switch (bubbleplus)
        {
        case 0:
            BubleCursor2.rectTransform.anchoredPosition = new Vector2(4.08f, -4.37f);
            break;

        case 1:
            BubleCursor2.rectTransform.anchoredPosition = new Vector2(4.08f, 12.25f);
            break;

        case 2:
            BubleCursor2.rectTransform.anchoredPosition = new Vector2(-4.63f, 4.1f);
            break;

        case 3:
            BubleCursor2.rectTransform.anchoredPosition = new Vector2(12.31f, 4.1f);
            break;

        case 4:
            BubleCursor2.rectTransform.anchoredPosition = new Vector2(4.01f, 4.01f);
            break;
        }

        BubleCursor2.sprite = BubleCursor.sprite;
        if (movecount != limitMove)
        {
            GetTextMove.gameObject.SetActive(true);//
            switch (state)
            {
            case 0:
                if (levelsApps.modeLvl == 2)
                {
                    StartCoroutine(IngredientScale());
                }
                if (Input.GetMouseButtonDown(1))
                {
                    rightMouseButtonDown = true;
                    var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector3.zero);
                    if (hit.collider != null)
                    {
                        //CurrentBlk = hit.collider.GetComponent<Block>();
                        var cndy = hit.collider.GetComponent <HitCandy>();
                        GetHitGem          = cndy; bubble2 = cndy;
                        BubleCursor.sprite = GetHitNext.GetComponent <SpriteRenderer>().sprite;
                        currentHits        = hit.collider.GetComponent <HitCandy>();
                        if (cndy != null && cndy.GetBlock.types == 1)
                        {
                            GameObject vblck = ((GameObject)Instantiate(blockpref, cndy.GetBlock.transform.position, Quaternion.identity));
                            vblck.GetComponent <Block>().row   = cndy.GetBlock.row;
                            vblck.GetComponent <Block>().col   = cndy.GetBlock.col;
                            vblck.GetComponent <Block>().types = 1;
                            GetBlockMove = vblck.GetComponent <Block>();
                            GetArrays[GetBlockMove.row, GetBlockMove.col] = new Gem(GetBlockMove.row, GetBlockMove.col);
                            GetArrays[GetBlockMove.row, GetBlockMove.col].Nil();
                            var lisp = GetArrays.GetProp2(cndy.GetBlock, cndy.GetBlock.row, cndy.GetBlock.col);
                            BlockParents.Add(GetBlockMove);
                            MoveCount      = lisp.GetGems.Count();
                            currentHitList = lisp.GetGems;
                            //GameObject vblck = ((GameObject)Instantiate(blockpref, levelsApps.vector2position + new Vector2(cndy.GetBlock.col * levelsApps.blckWH(), cndy.GetBlock.row * levelsApps.blckWH()), Quaternion.identity));
                            CurrentBlk          = cndy.GetBlock;
                            CurrentBlk.dontDest = true;
                            StartCoroutine(TryMatch(hit));
                            GetHitGem = cndy;
                            //foreach (var bb in MoveParents)
                            //{
                            //    if(bb.GetComponent<Block>().row==cndy.GetBlock.row
                            //        && bb.GetComponent<Block>().col == cndy.GetBlock.col)
                            //    {
                            //        GetBlockMove = bb;
                            //    }
                            //}
                            //state = 1;
                            //print(state);
                        }
                    }
                }
                if (Input.GetMouseButtonDown(0))
                {
                    rightMouseButtonDown = false;
                    var hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector3.zero);
                    if (hit.collider != null)
                    {
                        print(state);
                        CurrentBlk = hit.collider.GetComponent <Block>();
                        var cndy = hit.collider.GetComponent <HitCandy>();
                        currentHits = hit.collider.GetComponent <HitCandy>();
                        MoveParents.Add(CurrentBlk);
                        hit.collider.GetComponent <HitCandy>();
                        if (CurrentBlk != null)
                        {
                            if (GetHitGem == null)
                            {
                                GetHitGem = GetHitNext;

                                BubleCursor.sprite = GetHitNext.GetComponent <SpriteRenderer>().sprite;
                                GetHitNext         = GetCandyPrefab[Random.Range(0, GetCandyPrefab.Length)];
                                //BubleCursor.GetComponent<HitCandy>() = GetHitGem;
                                bubble2 = GetHitGem;
                                //if (GetHitGem != null)
                                //{
                                //    HitsCand.Add(GetHitGem);
                                //}
                                //if (bubble2 != null)
                                //{
                                //    HitsCand.Add(bubble2);
                                //}
                            }
                            CreateGem(CurrentBlk.row, CurrentBlk.col, GetHitGem);    //

                            switch (bubbleplus)
                            {
                            case 0:
                                CreateGem(CurrentBlk.row - 1, CurrentBlk.col, bubble2);
                                currentrow = CurrentBlk.row - 1;
                                currentcol = CurrentBlk.col;
                                break;

                            case 1:
                                CreateGem(CurrentBlk.row + 1, CurrentBlk.col, bubble2);
                                currentrow = CurrentBlk.row + 1;
                                currentcol = CurrentBlk.col;
                                break;

                            case 2:
                                CreateGem(CurrentBlk.row, CurrentBlk.col - 1, bubble2);
                                currentrow = CurrentBlk.row;
                                currentcol = CurrentBlk.col - 1;
                                break;

                            case 3:
                                CreateGem(CurrentBlk.row, CurrentBlk.col + 1, bubble2);
                                currentrow = CurrentBlk.row;
                                currentcol = CurrentBlk.col + 1;
                                break;

                            case 4:
                                break;

                            default:
                                break;
                            }
                            StartCoroutine(TryMatch(hit));
                            GetHitGem          = GetHitNext;
                            BubleCursor.sprite = GetHitNext.GetComponent <SpriteRenderer>().sprite;
                            GetHitNext         = GetCandyPrefab[Random.Range(0, GetCandyPrefab.Length)];
                            //BubleCursor.GetComponent<HitCandy>() = GetHitGem;
                            bubble2 = GetHitGem;
                            //if (GetHitGem != null)
                            //{
                            //    HitsCand.Add(GetHitGem);
                            //}
                            //if (bubble2 != null)
                            //{
                            //    HitsCand.Add(bubble2);
                            //}
                        }
                        if ((uint)levelsApps.ltype == 1)
                        {
                            //levelsApps.GetPause();
                        }
                        //GetHitGem.transform.position = new Vector3(Input.mousePosition.x, Input.mousePosition.y,0);
                        state = 0;
                    }
                }
                break;

            case 1:

                break;
            }
        }
    }
コード例 #16
0
 public void OnInit(HitCandy hitI)
 {
     candy = hitI;
     candy.isBlock(this);//
 }
コード例 #17
0
 public void Nil()
 {
     candy = null;
 }
コード例 #18
0
 public void OnInit(HitCandy hitI)
 {
     hitGem = hitI;
     hitGem.isGem(this);
 }
コード例 #19
0
 public bool isequal(HitCandy hitCandy)
 {
     return(hitCandy != null && hitCandy.type == type && hitCandy.type != "ingredient" + 0 && hitCandy.type != "ingredient" + 1);
 }