Ejemplo n.º 1
0
        private void GameView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                if (e.Button == MouseButtons.Right)
                {
                    if (GameView[e.ColumnIndex, e.RowIndex].Value.ToString() == " ")
                    {
                        GameView[e.ColumnIndex, e.RowIndex].Value = "#";

                        GameView[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.Yellow;
                    }
                    else if (GameView[e.ColumnIndex, e.RowIndex].Value.ToString() == "#")
                    {
                        GameView[e.ColumnIndex, e.RowIndex].Value = "?";

                        GameView[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.Gray;
                    }
                    else if (GameView[e.ColumnIndex, e.RowIndex].Value.ToString() == "?")
                    {
                        GameView[e.ColumnIndex, e.RowIndex].Value = " ";

                        GameView[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.White;
                    }
                }
                else
                {
                    if (//GameView[e.ColumnIndex, e.RowIndex].Value.ToString() == " " ||
                        //GameView[e.ColumnIndex, e.RowIndex].Value.ToString() == "0" ||
                        GameView[e.ColumnIndex, e.RowIndex].Value.ToString() != "#")
                    //GameView[e.ColumnIndex, e.RowIndex].Value.ToString() == "?")
                    {
                        int j = e.RowIndex;
                        int i = e.ColumnIndex;
                        //170321
                        int result = CheckFlags(i, j);

                        if (m_nMap[i, j] == 1 || result == -1) //BOOM
                        {
                            GameView.ClearSelection();
                            GameView[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.Red;

                            ShowAllBOOM();
                            GameView.ClearSelection();

                            timer1.Enabled   = false;
                            GameView.Enabled = false;

                            MessageBox.Show("Game Over!! You Lose!!");
                        }
                        // 170321
                        else if (result > 0)
                        {
                            GameView.CurrentCell = GameView.Rows[e.RowIndex].Cells[e.ColumnIndex];

                            if (result == 1)
                            {
                                int SurroundingBOOM = CheckSurroundingBOOM(i, j);
                                //GameView[e.ColumnIndex, e.RowIndex].Value = SurroundingBOOM;
                                //GameView[e.ColumnIndex, e.RowIndex].Style.BackColor = Color.PaleGreen;
                            }
                            OpenRemainingGreen();

                            if (Status)
                            {
                                timer1.Enabled   = false;
                                Status           = false;
                                GameView.Enabled = false;
                                MessageBox.Show("Horay!!You Win!!\n");

                                DisableSomeButton();
                            }
                        }
                    }
                    else if (GameView[e.ColumnIndex, e.RowIndex].Value.ToString() == "#")
                    {
                    }
                }
            }
        }