示例#1
0
        private async void btn_GameStart_Click(object sender, EventArgs e)
        {
            try
            {
                StartSetting(btn_GameStart);
                Tetris player1 = new Tetris(NewPanel(PanelValue.GetTetrisPanelToPlayer1()),
                                            NewPanel(PanelValue.GetNextBlockPanelToPlayer1()),
                                            lbl_Score, Keyboard.GetPlayer1, 1);
                TetrisAI player2 = TetrisAI.GeneralMode(NewPanel(PanelValue.GetTetrisPanelToPlayer2()),
                                                        NewPanel(PanelValue.GetNextBlockPanelToPlayer2()),
                                                        lbl_2pScore, 2, FileLoad <Weight>(FilePath.Weight));
                _game.PlayerAdd(player1);
                _game.PlayerAdd(player2);
                Size = new Size(690, 870);
                await _game.GameStart();
            }
#pragma warning disable 168
            catch (DirectoryNotFoundException _)
#pragma warning restore 168
            {
                AiNotFound();
            }
#pragma warning disable 168
            catch (FileNotFoundException _)
#pragma warning restore 168
            {
                AiNotFound();
            }
        }
示例#2
0
 private async void btn_1vs1_Click(object sender, EventArgs e)
 {
     StartSetting(btn_1vs1);
     Size = new Size(690, 870);
     _game.PlayerAdd(new Tetris(NewPanel(PanelValue.GetTetrisPanelToPlayer1()),
                                NewPanel(PanelValue.GetNextBlockPanelToPlayer1()),
                                lbl_Score, Keyboard.GetPlayer2, 1));
     _game.PlayerAdd(new Tetris(NewPanel(PanelValue.GetTetrisPanelToPlayer2()),
                                NewPanel(PanelValue.GetNextBlockPanelToPlayer2()),
                                lbl_2pScore, Keyboard.GetPlayer1, 2));
     await _game.GameStart();
 }
示例#3
0
        private TetrisPanel NewPanel(PanelValue panelValue)
        {
            TetrisPanel p = new TetrisPanel(30)
            {
                Location    = new Point(panelValue.PointX, panelValue.PointY),
                Size        = new Size(panelValue.Width, panelValue.Height),
                BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D,
                BackColor   = Color.Black
            };

            Controls.Add(p);
            _panels.Push(p);
            return(p);
        }
示例#4
0
        private async void btn_AI_Click(object sender, EventArgs e)
        {
            try
            {
                StartSetting(btn_AI);
                _game.PlayerAdd(TetrisAI.AITestMode(NewPanel(PanelValue.GetTetrisPanelToPlayer1()),
                                                    NewPanel(PanelValue.GetNextBlockPanelToPlayer1()),
                                                    lbl_Score, 1, FileLoad <Weight>(FilePath.Weight)));
                Size = new Size(360, 870);
                await _game.GameStart();
            }
#pragma warning disable 168
            catch (DirectoryNotFoundException _)
#pragma warning restore 168
            {
                AiNotFound();
            }
#pragma warning disable 168
            catch (FileNotFoundException _)
#pragma warning restore 168
            {
                AiNotFound();
            }
        }