private void btn_play_Click(object sender, EventArgs e)
        {
            myBoardGame.clearData();
            myBoardGame.setAI(flagAI);
            // Save all data setting to Object.
            //saveSettingToObjectMyGame();
            string size = "";

            foreach (DataGridViewRow row in dataGridViewLoadBoard.SelectedRows)
            {
                setXMLToObjectGame(row.Cells[1].Value.ToString()); // name file is keyword.
                size = row.Cells[2].Value.ToString();              // size
            }

            //if (colorSectionA != Color.Transparent && colorSectionB != Color.Transparent) {
            //    myBoardGame.setColorSection(colorSectionA, colorSectionB);

            //}
            myBoardGame.setColorSection(previewBoard.getColorSectionA(), previewBoard.getColorSectionB());
            //myBoardGame.setColorSection(colorSectionA, colorSectionB);

            if (size == "8 x 8")
            {
                myBoardGame.backup();
                FormPlay8x8 form = new FormPlay8x8(myBoardGame);
                form.Show();
                Hide();
                form.Location = this.Location;
                if (parentForm != null)
                {
                    parentForm.Close();
                }
            }
            else if (size == "12 x 12")
            {
                myBoardGame.backup();
                FormPlay12x12 form = new FormPlay12x12(myBoardGame);
                form.Show();
                Hide();
                form.Location = this.Location;
                if (parentForm != null)
                {
                    parentForm.Close();
                }
            }
        }
        private void btn_start_Click(object sender, EventArgs e)
        {
            if (state == "player1")
            {
                myBoardGame.setPlayerStart(1);
            }
            else if (state == "player2")
            {
                myBoardGame.setPlayerStart(2);
            }
            else   // random
            {
                Random rd           = new Random();
                int    randomNumber = rd.Next(0, 300);
                if (randomNumber % 2 == 0)
                {
                    myBoardGame.setPlayerStart(1);
                }
                else
                {
                    myBoardGame.setPlayerStart(2);
                }
            }

            if (myBoardGame.boardWidth == 8 && myBoardGame.boardHeight == 8)
            {
                FormPlay8x8 form = new FormPlay8x8(myBoardGame);
                form.Show();
                form.Location = parentForm.Location;
                Hide();
                parentForm.Close();
            }
            else if (myBoardGame.boardWidth == 12 && myBoardGame.boardHeight == 12)
            {
                FormPlay12x12 form = new FormPlay12x12(myBoardGame);
                form.Show();
                form.Location = parentForm.Location;
                Hide();
                parentForm.Close();
            }
        }
Пример #3
0
        private void btn_play_Click(object sender, EventArgs e)
        {
            // Save all data setting to Object.
            //saveSettingToObjectMyGame();
            string size = "";

            foreach (DataGridViewRow row in dataGridViewLoadBoard.SelectedRows)
            {
                setXMLToObjectGame(row.Cells[1].Value.ToString()); // name file is keyword.
                size = row.Cells[2].Value.ToString();              // size
            }

            //myBoardGame.setColorSection(colorSectionA, colorSectionB);

            if (size == "8 x 8")
            {
                FormPlay8x8 form = new FormPlay8x8(myBoardGame);
                form.Show();
                Hide();
                form.Location = this.Location;
            }
        }
Пример #4
0
        public void restartGame(Form oldForm, Form oldMenu)
        {
            string size = "" + this.boardWidth + " x " + this.boardHeight + "";

            this.recovery(); // recovery data in board started.

            if (size == "8 x 8")
            {
                //MetroMessageBox.Show(this, "Let Go!!!");
                FormPlay8x8 form = new FormPlay8x8(this);
                form.Show();
                oldForm.Hide();
                form.Location = oldForm.Location;
            }
            else if (size == "12 x 12")
            {
                //MetroMessageBox.Show(this, "Let Go!!!");
                FormPlay12x12 form = new FormPlay12x12(this);
                form.Show();
                oldForm.Hide();
                form.Location = oldForm.Location;
            }
            else
            {
                MessageBox.Show("This feature is not support.");
                FormMainMenu form = new FormMainMenu(this);
                form.Show();
                oldForm.Hide();
                form.Location = oldForm.Location;
            }

            if (oldMenu != null)
            {
                oldMenu.Close();
            }
            oldForm.Close();
        }