Ejemplo n.º 1
0
    void ViewBlockType()
    {
        Array ary = System.Enum.GetValues(typeof(BLOCKTYPPE));
        int   len = ary.Length;

        EditorGUILayout.LabelField("BLOCKTYPE", GUILayout.Width(90));

        for (int i = 0; i < len; i++)
        {
            int    enumVal  = (int)ary.GetValue(i);
            string enumName = System.Enum.GetName(typeof(BLOCKTYPPE), enumVal);

            if (GUILayout.Button(enumName, EditorStyles.miniButton, GUILayout.Width(120)))
            {
                if (m_SelectBlock != null)
                {
                    BlockHive info = m_SelectBlock.GetComponent <BlockHive>();
                    if (info != null)
                    {
                        info.SetBlockType((BLOCKTYPPE)enumVal);
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    void CrossUpNextCheck(Map.BLOCKCOLOR color, int index)     //홀수일때 옆에꺼 (+col) 짝수일때 한칸 위 + (col - 1)
    {
        //
        // row 가 짝수면 같은 라인. row가 홀수면 대각선 아래 검사
        //

        int NextCheckIndex = index + m_MapLoad.GetRowCount() - (((index / m_MapLoad.GetRowCount()) + 1) % 2);

        if (NextCheckIndex > m_MapLoad.GetRowCount() * m_MapLoad.GetColCount() || m_MapLoad.blocks[NextCheckIndex] == null)
        {
            TempMatchListIndex.Add(index);
            return;
        }

        BlockHive info  = m_MapLoad.blocks[index].GetComponent <BlockHive>();
        BlockHive info2 = m_MapLoad.blocks[NextCheckIndex].GetComponent <BlockHive>();

        if (info2.blockobj == null)
        {
            TempMatchListIndex.Add(index);
            return;
        }

        if (info.GetBlockInfo().color == info2.GetBlockInfo().color&& info2.GetBlockInfo().type == Map.BLOCKTYPPE.BLOCK)
        {
            TempMatchListIndex.Add(index);
            CrossUpNextCheck(color, NextCheckIndex);
        }
        else
        {
            TempMatchListIndex.Add(index);
        }
    }
Ejemplo n.º 3
0
    //
    // 대각선 업방향
    //


    void CrossUpMatchCheck()
    {
        for (int i = 0; i < m_MapLoad.blocks.Length; i++)
        {
            if (m_MapLoad.blocks[i] == null)
            {
                continue;
            }

            BlockHive info = m_MapLoad.blocks[i].GetComponent <BlockHive>();

            if (info.blockobj == null)
            {
                continue;
            }

            if (info.GetBlockInfo().type == Map.BLOCKTYPPE.BLOCK)
            {
                CrossUpNextCheck(info.GetBlockInfo().color, i);
            }

            if (TempMatchListIndex.Count >= 3)
            {
                for (int n = 0; n < TempMatchListIndex.Count; n++)
                {
                    if (!MatchList.Contains(m_MapLoad.blocks[TempMatchListIndex[n]]))
                    {
                        MatchList.Add(m_MapLoad.blocks[TempMatchListIndex[n]]);
                    }
                }
            }

            TempMatchListIndex.Clear();
        }
    }
Ejemplo n.º 4
0
    void DownNextCheck(Map.BLOCKCOLOR color, int index)
    {
        int NextCheckIndex = index + 1;

        if (NextCheckIndex > m_MapLoad.GetRowCount() * m_MapLoad.GetColCount() || m_MapLoad.blocks[NextCheckIndex] == null || NextCheckIndex % m_MapLoad.GetRowCount() == 0)
        {
            TempMatchListIndex.Add(index);
            return;
        }

        BlockHive info  = m_MapLoad.blocks[index].GetComponent <BlockHive>();
        BlockHive info2 = m_MapLoad.blocks[NextCheckIndex].GetComponent <BlockHive>();

        if (info2.blockobj == null)
        {
            TempMatchListIndex.Add(index);
            return;
        }

        if (info.GetBlockInfo().color == info2.GetBlockInfo().color&& info2.GetBlockInfo().type == Map.BLOCKTYPPE.BLOCK)
        {
            TempMatchListIndex.Add(index);
            DownNextCheck(color, NextCheckIndex);
        }
        else
        {
            TempMatchListIndex.Add(index);
        }
    }
Ejemplo n.º 5
0
    public void LoadBlock(Map.SAVEBLOCKDATA SaveMapdata, bool InGameLoad = false)
    {
        row = SaveMapdata.row;
        col = SaveMapdata.col;

        blocks = new GameObject[row * col];

        Transform go_parent = this.gameObject.transform;

        float xposInterval = Mathf.Sqrt(BLOCKWIDTH / 2);
        float startxpos    = (row * xposInterval) / 2 * -1 + (xposInterval / 2);
        float startypos    = (row * BLOCKHEIGHT) / 2;
        float halfheight   = BLOCKHEIGHT / 2;

        for (int r = 0; r < row; r++)
        {
            for (int c = 0; c < col; c++)
            {
                if (InGameLoad)
                {
                    if (SaveMapdata.blocks[(r * row) + (c)].type == Map.BLOCKTYPPE.NONE)
                    {
                        blocks[(r * row) + (c)] = null;
                        continue;
                    }
                }
                GameObject HiveGo = Instantiate <GameObject>(Resources.Load <GameObject>(BlockHivePath));
                HiveGo.transform.parent        = go_parent;
                HiveGo.transform.localPosition = Vector3.zero;
                float xpos = startxpos + (xposInterval * r);
                HiveGo.name = ((r * row) + c).ToString();
                int yInterval = r % 2;

                float ypos = startypos - (BLOCKHEIGHT * c) - (halfheight * yInterval);
                HiveGo.transform.localPosition = new Vector3(xpos, ypos, 0);

                blocks[(r * row) + (c)] = HiveGo;

                GameObject BlockGo = Instantiate <GameObject>(Resources.Load <GameObject>(BlockObjPath));

                BlockHive hive = HiveGo.GetComponent <BlockHive>();
                hive.SetBlockObject(BlockGo);
                hive.SetBlockColor(SaveMapdata.blocks[(r * row) + (c)].color);
                hive.SetBlockType(SaveMapdata.blocks[(r * row) + (c)].type);

                if (Game.instance != null)
                {
                    Game.instance.BlockPool.AddObjectNuse(BlockGo);
                }
            }
        }
    }
Ejemplo n.º 6
0
    //
    // 매치된 블럭을 풀에 반환 하고 비활성화 처리를 합니다.
    //
    void ReleaseBlock()
    {
        CreateBlockCount += MatchList.Count;

        for (int i = 0; i < MatchList.Count; i++)
        {
            BlockHive hiveinfo = MatchList[i].GetComponent <BlockHive>();

            BlockPool.ReturnPool(hiveinfo.blockobj.gameObject);
            hiveinfo.blockobj.gameObject.SetActive(false);
            hiveinfo.InitData();
        }

        MatchList.Clear();
    }
Ejemplo n.º 7
0
    IEnumerator CreateBlock()
    {
        while (true)
        {
            if (CreateBlockCount == 0)
            {
                break;
            }
            if (DropAnimaionCount == 0)
            {
                GameObject go = BlockPool.GetPool();

                BlockHive hiveinfo = CreateBlockPosition[0].GetComponent <BlockHive>();
                hiveinfo.SetBlockObject(go);
                hiveinfo.SetBlockType(Map.BLOCKTYPPE.BLOCK);
                hiveinfo.SetBlockColor((Map.BLOCKCOLOR)GetRandoomColor());
                go.transform.parent        = CreateBlockPosition[0].transform;
                go.transform.localPosition = Vector3.zero;
                go.SetActive(true);

                CreateBlockCount--;

                DropBlock();
                while (true)
                {
                    if (DropAnimaionCount == 0)
                    {
                        if (!WaterDrop())
                        {
                            break;
                        }
                    }
                    yield return(null);
                }

                MatchCheck();

                if (CreateBlockCount <= 0)
                {
                    break;
                }
            }

            yield return(null);
        }

        MoveDisAble = false;
    }
Ejemplo n.º 8
0
    public void CreateBlock(int row, int col)
    {
        this.row = row;
        this.col = col;

        blocks = new GameObject[row * col];

        Transform go_parent = this.gameObject.transform;

        float xposInterval = Mathf.Sqrt(BLOCKWIDTH / 2);
        float startxpos    = (row * xposInterval) / 2 * -1 + (xposInterval / 2);
        float startypos    = (row * BLOCKHEIGHT) / 2;
        float halfheight   = BLOCKHEIGHT / 2;

        for (int r = 0; r < row; r++)
        {
            for (int c = 0; c < col; c++)
            {
                GameObject HiveGo = Instantiate <GameObject>(Resources.Load <GameObject>(BlockHivePath));
                HiveGo.transform.parent        = go_parent;
                HiveGo.transform.localPosition = Vector3.zero;
                float xpos = startxpos + (xposInterval * r);
                HiveGo.name = ((r * row) + c).ToString();
                int yInterval = r % 2;

                float ypos = startypos - (BLOCKHEIGHT * c) - (halfheight * yInterval);
                HiveGo.transform.localPosition = new Vector3(xpos, ypos, 0);

                blocks[(r * row) + (c)] = HiveGo;

                GameObject BlockGo = Instantiate <GameObject>(Resources.Load <GameObject>(BlockObjPath));

                BlockHive hive = HiveGo.GetComponent <BlockHive>();
                hive.SetBlockObject(BlockGo);
                //hive.SetBlockColor(SaveMapdata.blocks[(r * row) + (c)].color);
                //hive.SetBlockType(SaveMapdata.blocks[(r * row) + (c)].type);

                blocks[(r * row) + (c)] = HiveGo;
            }
        }
    }
Ejemplo n.º 9
0
 bool FourMatchCheckColor(BlockHive hive1, BlockHive hive2, BlockHive hive3, BlockHive hive4)
 {
     if (hive1 != null &&
         hive2 != null &&
         hive3 != null &&
         hive4 != null &&
         hive1.blockobj != null &&
         hive2.blockobj != null &&
         hive3.blockobj != null &&
         hive4.blockobj != null &&
         hive1.GetBlockInfo().color == hive2.GetBlockInfo().color&&
         hive1.GetBlockInfo().color == hive3.GetBlockInfo().color&&
         hive1.GetBlockInfo().color == hive4.GetBlockInfo().color&&
         hive1.GetBlockInfo().type == Map.BLOCKTYPPE.BLOCK &&
         hive2.GetBlockInfo().type == Map.BLOCKTYPPE.BLOCK &&
         hive3.GetBlockInfo().type == Map.BLOCKTYPPE.BLOCK &&
         hive4.GetBlockInfo().type == Map.BLOCKTYPPE.BLOCK
         )
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 10
0
    void SetGoal()
    {
        for (int i = 0; i < m_MapLoad.blocks.Length; i++)
        {
            if (m_MapLoad.blocks[i] == null)
            {
                continue;
            }

            BlockHive info = m_MapLoad.blocks[i].GetComponent <BlockHive>();

            if (info.blockobj == null)
            {
                continue;
            }
            if (info.GetBlockInfo().type != Map.BLOCKTYPPE.NONE && info.GetBlockInfo().type != Map.BLOCKTYPPE.BLOCK)
            {
                Goal++;
            }
        }

        UIGame.instance.SetGoal(Goal);
    }
Ejemplo n.º 11
0
    void ReleaseObs()
    {
        //
        // 팽이 주변에 빈공간이 있다면 주변에서 매치가 되었으므로 다이카운트를 낮춰 준다.
        //
        for (int i = 0; i < m_MapLoad.blocks.Length; i++)
        {
            if (m_MapLoad.blocks[i] == null)
            {
                continue;
            }

            BlockHive info = m_MapLoad.blocks[i].GetComponent <BlockHive>();

            if (info.blockobj == null)
            {
                continue;
            }
            if (info.GetBlockInfo().type != Map.BLOCKTYPPE.NONE && info.GetBlockInfo().type != Map.BLOCKTYPPE.BLOCK)
            {
                if (ObsCheck(i))
                {
                    info.GetBlockInfo().DieCount--;
                }
            }
        }

        //
        // 다이카운트가 0이하인 장해물을 제거한다.
        //
        for (int i = 0; i < m_MapLoad.blocks.Length; i++)
        {
            if (m_MapLoad.blocks[i] == null)
            {
                continue;
            }

            BlockHive info = m_MapLoad.blocks[i].GetComponent <BlockHive>();

            if (info.blockobj == null)
            {
                continue;
            }

            if (info.blockobj == null)
            {
                continue;
            }

            if (info.GetBlockInfo().type != Map.BLOCKTYPPE.NONE && info.GetBlockInfo().type != Map.BLOCKTYPPE.BLOCK)
            {
                if (info.GetBlockInfo().DieCount <= 0)
                {
                    BlockPool.ReturnPool(info.blockobj.gameObject);
                    info.blockobj.gameObject.SetActive(false);
                    info.InitData();
                    CreateBlockCount++;
                    Goal--;
                    UIGame.instance.SetGoal(Goal);
                }
            }
        }
    }
Ejemplo n.º 12
0
    void FourMatchCheck()
    {
        int row = m_MapLoad.GetRowCount();
        int col = m_MapLoad.GetColCount();

        for (int i = 0; i < m_MapLoad.blocks.Length; i++)
        {
            if (m_MapLoad.blocks[i] == null)
            {
                continue;
            }

            BlockHive info = m_MapLoad.blocks[i].GetComponent <BlockHive>();

            int rowcount = i / row;

            if (info.blockobj == null)
            {
                continue;
            }

            if (info.GetBlockInfo().type == Map.BLOCKTYPPE.BLOCK)
            {
                if (rowcount % 2 == 0)
                {
                    int downIndex       = i + 1;
                    int crossupIndex    = i + col - 1;
                    int crossdownIndex  = i + col;
                    int crossdown2Index = i + col + 1;
                    int tworownextIndex = i + (col * 2);

                    GameObject down       = null;
                    GameObject crossup    = null;
                    GameObject crossdown  = null;
                    GameObject crossdown2 = null;
                    GameObject tworownext = null;

                    if (downIndex > 0 && downIndex < row * col)
                    {
                        down = m_MapLoad.blocks[downIndex];
                    }
                    if (crossupIndex > 0 && crossupIndex < row * col)
                    {
                        crossup = m_MapLoad.blocks[crossupIndex];
                    }
                    if (crossdownIndex > 0 && crossdownIndex < row * col)
                    {
                        crossdown = m_MapLoad.blocks[crossdownIndex];
                    }
                    if (crossdown2Index > 0 && crossdown2Index < row * col)
                    {
                        crossdown2 = m_MapLoad.blocks[crossdown2Index];
                    }
                    if (tworownextIndex > 0 && tworownextIndex < row * col)
                    {
                        tworownext = m_MapLoad.blocks[tworownextIndex];
                    }

                    BlockHive hivedown       = null;
                    BlockHive hivecrossup    = null;
                    BlockHive hivecrossdown  = null;
                    BlockHive hivecrossdown2 = null;
                    BlockHive hivetworownext = null;

                    if (down != null)
                    {
                        hivedown = down.GetComponent <BlockHive>();
                    }
                    if (crossup != null)
                    {
                        hivecrossup = crossup.GetComponent <BlockHive>();
                    }
                    if (crossdown != null)
                    {
                        hivecrossdown = crossdown.GetComponent <BlockHive>();
                    }
                    if (crossdown2 != null)
                    {
                        hivecrossdown2 = crossdown2.GetComponent <BlockHive>();
                    }
                    if (tworownext != null)
                    {
                        hivetworownext = tworownext.GetComponent <BlockHive>();
                    }

                    if (FourMatchCheckColor(info, hivecrossup, hivecrossdown, hivetworownext))
                    {
                        TempMatchListIndex.Add(i);
                        TempMatchListIndex.Add(crossupIndex);
                        TempMatchListIndex.Add(crossdownIndex);
                        TempMatchListIndex.Add(tworownextIndex);
                    }
                    if (FourMatchCheckColor(info, hivedown, hivecrossup, hivecrossdown))
                    {
                        TempMatchListIndex.Add(i);
                        TempMatchListIndex.Add(downIndex);
                        TempMatchListIndex.Add(crossupIndex);
                        TempMatchListIndex.Add(crossdownIndex);
                    }
                    if (FourMatchCheckColor(info, hivedown, hivecrossdown, hivecrossdown2))
                    {
                        TempMatchListIndex.Add(i);
                        TempMatchListIndex.Add(downIndex);
                        TempMatchListIndex.Add(crossdownIndex);
                        TempMatchListIndex.Add(crossdown2Index);
                    }
                }
                else
                {
                    int downIndex       = i + 1;              //18
                    int crossupIndex    = i + col;            //24
                    int crossdownIndex  = i + col + 1;        //25
                    int crossdown2Index = i + col + 2;        //26
                    int tworownextIndex = i + (col * 2);      //31

                    GameObject down       = null;
                    GameObject crossup    = null;
                    GameObject crossdown  = null;
                    GameObject crossdown2 = null;
                    GameObject tworownext = null;

                    if (downIndex > 0 && downIndex < row * col)
                    {
                        down = m_MapLoad.blocks[downIndex];
                    }
                    if (crossupIndex > 0 && crossupIndex < row * col)
                    {
                        crossup = m_MapLoad.blocks[crossupIndex];
                    }
                    if (crossdownIndex > 0 && crossdownIndex < row * col)
                    {
                        crossdown = m_MapLoad.blocks[crossdownIndex];
                    }
                    if (crossdown2Index > 0 && crossdown2Index < row * col)
                    {
                        crossdown2 = m_MapLoad.blocks[crossdown2Index];
                    }
                    if (tworownextIndex > 0 && tworownextIndex < row * col)
                    {
                        tworownext = m_MapLoad.blocks[tworownextIndex];
                    }


                    BlockHive hivedown       = null;
                    BlockHive hivecrossup    = null;
                    BlockHive hivecrossdown  = null;
                    BlockHive hivecrossdown2 = null;
                    BlockHive hivetworownext = null;

                    if (down != null)
                    {
                        hivedown = down.GetComponent <BlockHive>();
                    }
                    if (crossup != null)
                    {
                        hivecrossup = crossup.GetComponent <BlockHive>();
                    }
                    if (crossdown != null)
                    {
                        hivecrossdown = crossdown.GetComponent <BlockHive>();
                    }
                    if (crossdown2 != null)
                    {
                        hivecrossdown2 = crossdown2.GetComponent <BlockHive>();
                    }
                    if (tworownext != null)
                    {
                        hivetworownext = tworownext.GetComponent <BlockHive>();
                    }

                    if (FourMatchCheckColor(info, hivecrossup, hivecrossdown, hivetworownext))                    //17 24 25 31
                    {
                        TempMatchListIndex.Add(i);
                        TempMatchListIndex.Add(crossupIndex);
                        TempMatchListIndex.Add(crossdownIndex);
                        TempMatchListIndex.Add(tworownextIndex);
                    }
                    if (FourMatchCheckColor(info, hivedown, hivecrossup, hivecrossdown))
                    {
                        TempMatchListIndex.Add(i);
                        TempMatchListIndex.Add(downIndex);
                        TempMatchListIndex.Add(crossupIndex);
                        TempMatchListIndex.Add(crossdownIndex);
                    }
                    if (FourMatchCheckColor(info, hivedown, hivecrossdown, hivecrossdown2))
                    {
                        TempMatchListIndex.Add(i);
                        TempMatchListIndex.Add(downIndex);
                        TempMatchListIndex.Add(crossdownIndex);
                        TempMatchListIndex.Add(crossdown2Index);
                    }
                }
            }

            if (TempMatchListIndex.Count >= 4)
            {
                for (int n = 0; n < TempMatchListIndex.Count; n++)
                {
                    if (!MatchList.Contains(m_MapLoad.blocks[TempMatchListIndex[n]]))
                    {
                        MatchList.Add(m_MapLoad.blocks[TempMatchListIndex[n]]);
                    }
                }
            }

            TempMatchListIndex.Clear();
        }
    }