Exemplo n.º 1
0
 private void btnPlay_Click(object sender, RoutedEventArgs e)
 {
     if (rdbhuman.IsChecked == false && rdbcomputer.IsChecked == false)
     {
         MessageBox.Show("Chọn chế độ chơi", "Thông báo");
     }
     else
     {
         if (test == 0 && txtname2.Text == "Máy" && txtname1.Text != "")
         {
             BanCo.Option.PlayerAName = txtname1.Text;
             BanCo.Option.PlayerBName = txtname2.Text;
             Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), "Trò chơi bắt đầu");
             chatBox.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
             chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
             chatBox.Items.Add(Messege);
             banco.NewGame();
         }
         else if (txtname1.Text != "" && txtname2.Text != "" && test == 1)
         {
             BanCo.Option.PlayerAName = txtname1.Text;
             BanCo.Option.PlayerBName = txtname2.Text;
             Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), "Trò chơi bắt đầu");
             chatBox.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
             chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
             chatBox.Items.Add(Messege);
             banco.NewGame();
         }
         else
         {
             MessageBox.Show(" Chưa nhập tên người chơi", "Thông báo");
         }
     }
 }
Exemplo n.º 2
0
        private void Chonchedo_Click(object sender, RoutedEventArgs e)
        {
            if (cbCheDo.Text == "Human vs Human")
            {
                btnstart.IsEnabled = false;
                btnSend.IsEnabled  = false;
                banco.NewGame();
                BanCo.Option.WhoPlayWith = Player.Human;
                test = 1;
            }
            if (cbCheDo.Text == "Human vs AI")
            {
                btnstart.IsEnabled = false;
                btnSend.IsEnabled  = false;
                banco.NewGame();
                BanCo.Option.WhoPlayWith = Player.Com;
                test = 0;
            }
            if (cbCheDo.Text == "Human vs Human Online")
            {
                btnstart.IsEnabled = true;
                btnSend.IsEnabled  = true;
                UI = 1;
                if (dem == 0)
                {
                    socket = IO.Socket(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);


                    BanCo.Option.WhoPlayWith = Player.Online;

                    BanCo.currPlayer = Player.Online;
                    connect.connected(socket, txtYourName.Text.ToString());
                    dem++;
                }

                if (newgame1 == true)
                {
                    banco.PlayAgain();
                    socket = IO.Socket(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
                    BanCo.Option.WhoPlayWith = Player.Online;
                    BanCo.currPlayer         = Player.Online;
                    connect.connected(socket, txtYourName.Text.ToString());
                    connect.rw = -1;
                    connect.cl = -1;
                    newgame1   = false;
                }
            }
            if (cbCheDo.Text == "Human vs AI online")
            {
                btnstart.IsEnabled = true;
                btnSend.IsEnabled  = true;
                UI = 1;
                if (dem1 == 0)
                {
                    socket = IO.Socket(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);


                    BanCo.Option.WhoPlayWith = Player.MayOnline;
                    BanCo.currPlayer         = Player.Human;
                    connect.connected(socket, txtYourName.Text.ToString());
                    dem1++;
                }
                else
                {
                    connect.changname(socket, txtYourName.Text);
                }
                if (newgame == true)
                {
                    banco.PlayAgain();
                    socket = IO.Socket(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);


                    BanCo.Option.WhoPlayWith = Player.MayOnline;
                    BanCo.currPlayer         = Player.Human;
                    connect.connected(socket, txtYourName.Text.ToString());
                    connect.rw1 = -1;
                    connect.cl1 = -1;
                    newgame     = false;
                }
            }
        }