예제 #1
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     mainMenu = new FormMenu(true);
     Application.Run(mainMenu);
 }
예제 #2
0
        /* Calling the menu by clicking on the button
         */
        private void btnMenu_Click(object sender, EventArgs e)
        {
            FormMenu     menu   = new FormMenu(false);
            DialogResult result = menu.ShowDialog();

            // Processing the result
            switch (result)
            {
            // Continue
            case DialogResult.Cancel:
                LoadLocalizedText();
                break;

            // A new game
            case DialogResult.OK:
                phase = !phase;
                Game.InitEngine(ref gameBoard, ref rtbUserLog, phase, menu.aiAffected);
                if (Game.gameplayController.state.IsAiControlled)
                {
                    if (Game.gameplayController.state.AiSide == Helpers.Enums.CheckerSide.White)
                    {
                        Game.gameplayController.AiTurn();
                    }
                }
                GC.Collect();
                break;

            // Save game
            case DialogResult.Abort:
                SaveFileDialog saveDialog = new SaveFileDialog();
                saveDialog.Filter = "Polygon checkers save file|*.plchckr";
                if (saveDialog.ShowDialog() == DialogResult.OK)
                {
                    Game.Save(saveDialog.FileName);
                }
                break;

            // Load game
            case DialogResult.Retry:
                OpenFileDialog openDialog = new OpenFileDialog();
                openDialog.Filter = "Polygon checkers save file|*.plchckr";
                if (openDialog.ShowDialog() == DialogResult.OK)
                {
                    Game.Load(openDialog.FileName);
                }
                break;

            default:
                break;
            }
        }