示例#1
0
 private void saveSettingToObjectMyGame()
 {
     myBoardGame.setSizeBoard(boardWidth, boardHeight);
     //myBoardGame.setRowItem(rowItem);
     //myBoardGame.setColorSection(colorSectionA,colorSectionB); // have bug when player not choose button.
     myBoardGame.setColorSection(previewBoard.getColorSectionA(), previewBoard.getColorSectionB());
     myBoardGame.setAI(flagAI);
 }
        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();
                }
            }
        }