private void btn_quit_Click(object sender, EventArgs e)
        {
            // Navigate Page.
            myBoardGame.clearData();
            FormMainMenu form = new FormMainMenu(myBoardGame);

            form.Show();
            Hide();
            form.Location = parentForm.Location;
            parentForm.Close();
        }
        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();
                }
            }
        }
示例#3
0
        private void btn_export_Click(object sender, EventArgs e)
        {
            int[,] tablePlayerHolder = new int[boardHeight, boardWidth];
            int[,] tableStatusItem   = new int[boardHeight, boardWidth];
            int count_player1 = 0;
            int count_player2 = 0;

            for (int i = 0; i < boardHeight; i++)
            {
                for (int j = 0; j < boardWidth; j++)
                {
                    if (btnSection[i, j].BackColor == btn_status[1])
                    {
                        tablePlayerHolder[i, j] = 1;
                        tableStatusItem[i, j]   = 1;
                        count_player1++;
                    }
                    else if (btnSection[i, j].BackColor == btn_status[2])
                    {
                        tablePlayerHolder[i, j] = 1;

                        if (radio_makNeeb.Checked) // mak neeb not hav super.
                        {
                            tableStatusItem[i, j] = 1;
                        }
                        else
                        {
                            tableStatusItem[i, j] = 2;
                        }

                        count_player1++;
                    }
                    else if (btnSection[i, j].BackColor == btn_status[3])
                    {
                        tablePlayerHolder[i, j] = 2;
                        tableStatusItem[i, j]   = 1;
                        count_player2++;
                    }
                    else if (btnSection[i, j].BackColor == btn_status[4])
                    {
                        tablePlayerHolder[i, j] = 2;

                        if (radio_makNeeb.Checked) // mak neeb not hav super.
                        {
                            tableStatusItem[i, j] = 1;
                        }
                        else
                        {
                            tableStatusItem[i, j] = 2;
                        }

                        count_player2++;
                    }
                    else
                    {
                        tablePlayerHolder[i, j] = 0;
                        tableStatusItem[i, j]   = 0;
                    }

                    // set Hsuper , prevent bug.
                    if (i == 0 && btnSection[i, j].BackColor == btn_status[3])
                    {
                        tableStatusItem[i, j] = 2;
                    }
                    else if (i == boardHeight - 1 && btnSection[i, j].BackColor == btn_status[1])
                    {
                        tableStatusItem[i, j] = 2;
                    }
                }
            }

            if (count_player1 > 0 && count_player1 <= 20 && count_player2 > 0 && count_player1 <= 20)
            {
                //MessageBox.Show(count_player1 + "  - " + count_player2);
                if (radio_makHorse.Checked)
                {
                    myBoardGame.setTypeBoard("Mak Horse");
                }
                else if (radio_makNeeb.Checked)
                {
                    myBoardGame.setTypeBoard("Mak Neeb");
                }

                myBoardGame.clearData();
                myBoardGame.setSizeBoard(boardWidth, boardHeight);
                myBoardGame.updateTableTolist(tablePlayerHolder, tableStatusItem);
                FormSavePage form = new FormSavePage(this, myBoardGame);  // load save form.
                form.Show();
                //Hide();
                form.Location = new Point(this.Location.X + (this.Width / 4), this.Location.Y + (this.Height / 4));
            }
            else
            {
                MessageBox.Show("Sorry , each player should have item more than 1 and less than 20.");
            }
        }