コード例 #1
0
        // 특정 색상 모두 캔디 종류 변경하기
        public void OneColor_Fruit_Change_All_Special(int get_fruit_Type, e_Boom_Number_Type _enum)
        {
            int WhatBoom = 0;

            if (_enum == e_Boom_Number_Type.VerticalBoom)
            {
                WhatBoom = 5;
            }
            if (_enum == e_Boom_Number_Type.HorizontalBoom)
            {
                WhatBoom = 10;
            }
            if (_enum == e_Boom_Number_Type.BagBoom)
            {
                WhatBoom = 15;
            }

            for (int x = 0; x < 9; x++)
            {
                for (int y = 0; y < 10; y++)
                {
                    if (gm.GetBlockObject(x, y) != null && gm.Get_ImBlock(x, y).Fruit_Type % 5 == get_fruit_Type % 5)
                    {
                        gm.candy_Init.Init(gm.GetBlockObject(x, y), (get_fruit_Type % 5) + WhatBoom);
                    }
                }
            }
        }
コード例 #2
0
        public int Match3_Algorithm()
        {
            // isMatched 이중배열 0으로 초기화
            for (int i = 0; i < 9; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    BoomType[i, j]      = 0;
                    isMatched[i, j]     = 0;
                    BagBoom_Check[i, j] = 0;
                }
            }
            int Sum = 0;

            Sum = GetThreeMatch();
            // isMatched 이중배열을 검사해서
            // 0 이상이면 파괴한다.
            // 파괴하면서 세로,가로줄 파괴하는 특수 폭탄인지 검사.
            for (int i = 0; i < 9; i++)
            {
                for (int j = 1; j < 10; j++)
                {
                    if (isMatched[i, j] > 0 && gm.GetBlockObject(i, j))
                    {
                        //Debug.Log($"브레이킹[{i},{j}] 발동 + Matched : {isMatched[i,j]}");

                        if (BagBoom_Check[i, j] == 2)
                        {
                            gm.candy_Init.Init(gm.GetBlockObject(i, j), gm.Get_ImBlock(i, j).Fruit_Type + 15);
                        }
                        else if (isMatched[i, j] == 4 && BoomType[i, j] == (int)Functions.e_Boom_Number_Type.VerticalBoom)
                        {
                            gm.candy_Init.Init(gm.GetBlockObject(i, j), gm.Get_ImBlock(i, j).Fruit_Type + 5);
                        }
                        else if (isMatched[i, j] == 4 && BoomType[i, j] == (int)Functions.e_Boom_Number_Type.HorizontalBoom)
                        {
                            gm.candy_Init.Init(gm.GetBlockObject(i, j), gm.Get_ImBlock(i, j).Fruit_Type + 10);
                        }
                        else if (isMatched[i, j] == 5)
                        {
                            // 컬러밤 생성
                            gm.candy_Init.Init(gm.GetBlockObject(i, j), 100);
                        }
                        else
                        {
                            gm.breaking.Break(i, j);
                        }
                    }
                }
            }
            return(Sum);
        }
コード例 #3
0
 /*
  *  캔디가 파괴할때 실행되는 함수
  *  캔디크러쉬사가에서는
  *  4개가 가로, 세로 직선으로있을때
  *  가로일때 - 세로줄 파괴 캔디 1개 생성
  *  세로일때 - 가로줄 파괴 캔디 1개 생성
  *  5개가 직선으로 있을때
  *  ColorBoom이 생성되고 ColorBoom을 움직이면
  *  ColorBoom과 바꾼 Fruit을 보드에서 모두 파괴한다. (가로 세로일 경우 효과 발동됨)
  */
 public void Break(int i, int j)
 {
     if (gm.GetBoardState(i, j))
     {
         if (gm.GetBlockObject(i, j) != null)
         {
             if (gm.Get_ImBlock(i, j).VerticalBoom == 1)
             {
                 gm.Get_ImBlock(i, j).VerticalBoom = 0;
                 Debug.Log($"VerticalExplode [{i},{j}]");
                 Line_Explode(i, j, (int)e_Boom_Number_Type.VerticalBoom);
             }
             else if (gm.Get_ImBlock(i, j).HorizontalBoom == 1)
             {
                 gm.Get_ImBlock(i, j).HorizontalBoom = 0;
                 Debug.Log($"HorizontalExplode [{i},{j}]");
                 Line_Explode(i, j, (int)e_Boom_Number_Type.HorizontalBoom);
             }
             else if (gm.Get_ImBlock(i, j).BagBoom == 1)
             {
                 gm.Get_ImBlock(i, j).BagBoom = 0;
                 Bag_Explode(i, j, 1);
             }
             else
             {
                 gm.SleepBlocks.Enqueue(gm.GetBlockObject(i, j));
                 gm.GetBlockObject(i, j).SetActive(false);
                 gm.c_board.V[i].H[j].block.HereBlockObject = null;
                 gm.values.iPoint += 10;
                 gm.values.SetPointText();
             }
         }
     }
 }
コード例 #4
0
        public bool CheckPredictedCase()
        {
            List <C_ImBlock> checkList = new List <C_ImBlock>();

            for (int x = 0; x < 9; ++x)
            {
                for (int y = 1; y <= 9; ++y)
                {
                    for (int k = 0; k < 4; ++k)
                    {
                        if (gm.GetBlockObject(x, y) == null)
                        {
                            continue;
                        }
                        int resultX = x + dx[k];
                        int resultY = y + dy[k];
                        // 우좌 상하 순으로 이동했을때의 경우에서 매치가 되는부분을 탐색
                        if (resultX < 0 || resultX >= 9 || resultY <= 0 || resultY >= 10) //넘어가는지
                        {
                            continue;
                        }
                        if (gm.GetBlockObject(resultX, resultY) == null)
                        {
                            continue;
                        }


                        CheckLine(resultX, resultY, k, gm.Get_ImBlock(x, y).Fruit_Type, ref checkList);
                        if (checkList.Count >= 2) //현 블럭을 제외
                        {
                            //반짝이 처리
                            checkList.Add(gm.Get_ImBlock(x, y));    //현 리스트에는 탐색을 시작하는 칸이 없었기에 넣어줌
                            foreach (C_ImBlock tBlock in checkList) //리스트에 들어있는 블럭들의 색 변화 fill함수가 호출될때마다 색을 리셋 시켜줘야함
                            {
                                tBlock.GetComponent <Image>().color = new Color(1.0f, 1.0f, 1.0f, 0.3f);
                            }
                            return(true);
                        }
                        else
                        {
                            checkList.Clear();
                        }
                    }
                }
            }
            return(false); //가능한 경우가 없다는 의미
        }
コード例 #5
0
        // 스왑기능
        public void Swap(int xLine, int yLine, int s_xLine, int s_yLine)
        {
            // 게임 로직이 2일때
            if (gm.Game_Logic_State == 2)
            {
                GameObject tempobj;
                tempobj = gm.GetBlockObject(xLine, yLine);
                gm.c_board.V[xLine].H[yLine].block.HereBlockObject     = gm.GetBlockObject(s_xLine, s_yLine);
                gm.c_board.V[s_xLine].H[s_yLine].block.HereBlockObject = tempobj;

                First  = gm.Get_ImBlock(xLine, yLine);
                Second = gm.Get_ImBlock(s_xLine, s_yLine);
                Special_BoomCount_Check();

                xy.X   = xLine;
                xy.Y   = yLine;
                s_xy.X = s_xLine;
                s_xy.Y = s_yLine;
                int Sum = 0;

                // 마우스 이동방향 오브젝트와 Swap 후
                // 3Match가능한지 검사
                // Sum값이 1 이상이면 바꾸기 가능이므로 애니메이션 실행
                // 0 이하일 경우 불가능 하므로 갔다오는 애니메이션을 실행한 후 다시 Swap (원상태)
                Sum = gm.match_Finder.GetThreeMatch();

                if (SpecialBoomCount == 2 || ColorBoomCount == 1)
                {
                    EventManager.Emit("MatchComplete");
                    Special_Swap();
                    gm.Game_Logic_State = 1;
                    gm.ChangeLogicTimer(0.3f);
                }
                // Sum > 0 바꾸기 가능
                else if (Sum > 0)
                {
                    EventManager.Emit("MatchComplete");
                    gm.Get_ImBlock(xLine, yLine).MoveEnQueue(xy);
                    gm.Get_ImBlock(s_xLine, s_yLine).MoveEnQueue(s_xy);
                    gm.ChangeLogicTimer(0.1f);
                    gm.Game_Logic_State = 0;
                }
                // Sum == 0 바꾸기 불가능
                // 다시 되돌리기.
                else
                {
                    gm.Get_ImBlock(xLine, yLine).MoveEnQueue(xy);
                    gm.Get_ImBlock(s_xLine, s_yLine).MoveEnQueue(s_xy);
                    tempobj = gm.GetBlockObject(xLine, yLine);
                    gm.c_board.V[xLine].H[yLine].block.HereBlockObject     = gm.GetBlockObject(s_xLine, s_yLine);
                    gm.c_board.V[s_xLine].H[s_yLine].block.HereBlockObject = tempobj;
                    gm.Get_ImBlock(xLine, yLine).MoveEnQueue(xy, 0.1f);
                    gm.Get_ImBlock(s_xLine, s_yLine).MoveEnQueue(s_xy, 0.1f);
                    gm.ChangeLogicTimer(0.2f);
                    gm.Game_Logic_State = 2;
                }

                // 스왑이 끝나면 다음 액션을 할 수 있도록 Logic Ready 값을 바꿔줌.
                // GameManager.CS 의 Game_Routine 코루틴 참조
                gm.Next_Logic_Ready = false;
            }
        }