예제 #1
0
파일: Demining.cs 프로젝트: CodFrm/Demining
        private void OpenMap(BombButton btn)
        {
            if (btn.m_nState != 3)
            {
                m_nRemain--;
                if (btn.m_nBoomAmount == 0)
                {
                    btn.SetState(3);

                    int x = btn.m_Pos.X, y = btn.m_Pos.Y;
                    if ((x - 1) >= 0)//开左边
                    {
                        BombButton tmpBtnLeft = (BombButton)m_arrLattice[(x - 1) * m_nHight + y];
                        OpenMap(tmpBtnLeft);
                        if ((y - 1) >= 0)//左上
                        {
                            BombButton tmpBtnLeftUp = (BombButton)m_arrLattice[(x - 1) * m_nHight + (y - 1)];
                            OpenMap(tmpBtnLeftUp);
                        }
                        if ((y + 1) < m_nHight)//左下
                        {
                            BombButton tmpBtnLeftUp = (BombButton)m_arrLattice[(x - 1) * m_nHight + (y + 1)];
                            OpenMap(tmpBtnLeftUp);
                        }
                    }
                    if ((x + 1) < m_nWidth)//开右边
                    {
                        BombButton tmpBtnRight = (BombButton)m_arrLattice[(x + 1) * m_nHight + y];
                        OpenMap(tmpBtnRight);
                        if ((y - 1) >= 0)//右上
                        {
                            BombButton tmpBtnRightUp = (BombButton)m_arrLattice[(x + 1) * m_nHight + (y - 1)];
                            OpenMap(tmpBtnRightUp);
                        }
                        if ((y + 1) < m_nHight)//右下
                        {
                            BombButton tmpBtnRightUp = (BombButton)m_arrLattice[(x + 1) * m_nHight + (y + 1)];
                            OpenMap(tmpBtnRightUp);
                        }
                    }
                    if ((y - 1) >= 0)//开上边
                    {
                        BombButton tmpBtn = (BombButton)m_arrLattice[x * m_nHight + (y - 1)];
                        OpenMap(tmpBtn);
                    }
                    if ((y + 1) < m_nHight)//开下边
                    {
                        BombButton tmpBtn = (BombButton)m_arrLattice[x * m_nHight + (y + 1)];
                        OpenMap(tmpBtn);
                    }
                }
            }
            btn.SetState(3);
        }