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); } }
// // 대각선 업방향 // 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(); } }
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); } }
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); }
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); }
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); } } } }
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(); } }