示例#1
0
        private void txt_change(object sender, TextChangedEventArgs e)
        {
            if (BanCo.currPlayer == Player.Online && BanCo.end == Player.None)
            {
                BanCo.board[BanCo.rows, BanCo.columns] = BanCo.currPlayer; //Lưu loại cờ vừa đánh vào mảng
                BanCo.DrawDataBoard(BanCo.rows, BanCo.columns, true, true);
                BanCo.end = BanCo.CheckEnd(BanCo.rows, BanCo.columns);     //Kiểm tra xem trận đấu kết thúc chưa

                if (BanCo.end == Player.Online)                            //Nếu người chơi 2 thắng
                {
                    BanCo.OnWin();                                         //Khai báo sư kiện Win
                    BanCo.OWinorLose();                                    //Hiển thị 5 ô Win.
                    Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), name + " là người thắng");
                    chatBox.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                    chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                    chatBox.Items.Add(Messege);
                    btnonline.Content = "New game";
                    newgame1          = true;
                }
                else
                {
                    BanCo.currPlayer = Player.Human; //Thiết lập lại lượt chơi
                    BanCo.OnComDanhXong();           // Khai báo sự kiện người chơi 2 đánh xong
                }
            }
        }
示例#2
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");
         }
     }
 }
示例#3
0
        private void btnPlayerAgain_Click(object sender, RoutedEventArgs e)
        {
            Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), "Ván mới");

            chatBox.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
            chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            chatBox.Items.Add(Messege);
            MessageBox.Show("Bắt đầu chơi !!!", "Thông báo");
            banco.PlayAgain();
        }
示例#4
0
        private void banco_WinEvent()
        {
            if (banco.End == Player.Human && BanCo.Option.WhoPlayWith == Player.Com || banco.End == Player.Human && BanCo.Option.WhoPlayWith == Player.Human)
            {
                string temp1 = BanCo.Option.PlayerAName + " " + "là người chiến thắng";

                Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), temp1);
                chatBox.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                chatBox.Items.Add(Messege);
            }
            if (banco.End == Player.Com && BanCo.Option.WhoPlayWith == Player.Human)
            {
                string temp2 = BanCo.Option.PlayerBName + "là người chiến thắng";

                Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), temp2);
                chatBox.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                chatBox.Items.Add(Messege);
            }
            if (banco.End == Player.Human && BanCo.Option.WhoPlayWith == Player.Online)
            {
                btnonline.Content = "New game";
                string temp2 = txtYourName.Text + "là người chiến thắng";

                Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), temp2);
                chatBox.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                chatBox.Items.Add(Messege);
            }
            if (banco.End == Player.Online && BanCo.Option.WhoPlayWith == Player.Online)
            {
                string temp2 = MainWindow.name + "là người chiến thắng";

                Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), temp2);
                chatBox.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                chatBox.Items.Add(Messege);
            }
            if (banco.End == Player.Human && BanCo.Option.WhoPlayWith == Player.MayOnline)
            {
                string temp2 = MainWindow.name + "là người chiến thắng";

                Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), temp2);
                chatBox.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                chatBox.Items.Add(Messege);
            }
        }
示例#5
0
 private void Message_SelectionChanged(object sender, RoutedEventArgs e)
 {
     if (MainWindow.name != null)
     {
         Messege Messege = new Messege(MainWindow.name, DateTime.Now.ToString("hh:mm:ss tt"), message);
         chatBox.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
         chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
         chatBox.Items.Add(Messege);
     }
     else
     {
         Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), message);
         chatBox.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
         chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
         chatBox.Items.Add(Messege);
     }
 }
示例#6
0
        private void banco_LoseEvent()
        {
            if (BanCo.Option.WhoPlayWith == Player.Com && banco.End == Player.Com)
            {
                Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), "Cố lên nhé");
                chatBox.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                chatBox.Items.Add(Messege);
            }
            if (banco.End == Player.Com && BanCo.Option.WhoPlayWith == Player.MayOnline)
            {
                string temp2 = txtYourName.Text + "là người chiến thắng";

                Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), temp2);
                chatBox.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                chatBox.Items.Add(Messege);
            }
        }
示例#7
0
        private void btnmayonline_Click(object sender, RoutedEventArgs e)
        {
            if (dem1 == 0)
            {
                socket = IO.Socket(ConfigurationManager.ConnectionStrings["chuoi"].ConnectionString);
                btnmayonline.Content     = "Change";
                BanCo.Option.GamePlay    = LuatChoi.Vietnamese;
                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)
            {
                Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), "Ván mới");
                chatBox.VerticalAlignment   = System.Windows.VerticalAlignment.Top;
                chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                chatBox.Items.Add(Messege);
                MessageBox.Show("Bắt đầu chơi !!!", "Thông báo");
                banco.PlayAgain();
                socket = IO.Socket(ConfigurationManager.ConnectionStrings["chuoi"].ConnectionString);
                btnmayonline.Content     = "Change";
                BanCo.Option.GamePlay    = LuatChoi.Vietnamese;
                BanCo.Option.WhoPlayWith = Player.MayOnline;
                BanCo.currPlayer         = Player.Human;
                connect.connected(socket, txtYourName.Text.ToString());
                connect.rw1 = -1;
                connect.cl1 = -1;
                newgame     = false;
            }
        }
示例#8
0
 private void Message_SelectionChanged(object sender, RoutedEventArgs e)
 {
     if (MainWindow.name != null)
     {
         Messege Messege = new Messege(MainWindow.name, DateTime.Now.ToString("hh:mm:ss tt"), message);
         chatBox.VerticalAlignment = System.Windows.VerticalAlignment.Top;
         chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
         chatBox.Items.Add(Messege);
     }
     else
     {
         Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), message);
         chatBox.VerticalAlignment = System.Windows.VerticalAlignment.Top;
         chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
         chatBox.Items.Add(Messege);
     }
 }
示例#9
0
        private void btnmayonline_Click(object sender, RoutedEventArgs e)
        {
            if (dem1 == 0)
            {
                socket = IO.Socket(ConfigurationManager.ConnectionStrings["chuoi"].ConnectionString);
                btnmayonline.Content = "Change";
                BanCo.Option.GamePlay = LuatChoi.Vietnamese;
                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)
            {
                Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), "Ván mới");
                chatBox.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                chatBox.Items.Add(Messege);
                MessageBox.Show("Bắt đầu chơi !!!", "Thông báo");
                banco.PlayAgain();
                socket = IO.Socket(ConfigurationManager.ConnectionStrings["chuoi"].ConnectionString);
                btnmayonline.Content = "Change";
                BanCo.Option.GamePlay = LuatChoi.Vietnamese;
                BanCo.Option.WhoPlayWith = Player.MayOnline;
                BanCo.currPlayer = Player.Human;
                connect.connected(socket, txtYourName.Text.ToString());
                connect.rw1 = -1;
                connect.cl1 = -1;
                newgame = false;
            }
        }
示例#10
0
 private void btnPlayerAgain_Click(object sender, RoutedEventArgs e)
 {
         Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), "Ván mới");
         chatBox.VerticalAlignment = System.Windows.VerticalAlignment.Top;
         chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
         chatBox.Items.Add(Messege);   
     MessageBox.Show("Bắt đầu chơi !!!","Thông báo");
     banco.PlayAgain();
 }
示例#11
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");
                }
            }
        }
示例#12
0
        private void banco_WinEvent()
        {

            if (banco.End == Player.Human && BanCo.Option.WhoPlayWith == Player.Com|| banco.End == Player.Human && BanCo.Option.WhoPlayWith == Player.Human)
            {
                string temp1 =  BanCo.Option.PlayerAName + " " + "là người chiến thắng";

                    Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), temp1);
                    chatBox.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                    chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                    chatBox.Items.Add(Messege);
           }
            if (banco.End == Player.Com && BanCo.Option.WhoPlayWith == Player.Human)
            {
                string temp2 =  BanCo.Option.PlayerBName + "là người chiến thắng";

                    Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), temp2);
                    chatBox.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                    chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                    chatBox.Items.Add(Messege);
            }
            if (banco.End == Player.Human && BanCo.Option.WhoPlayWith == Player.Online)
            {
                btnonline.Content = "New game";
                string temp2 = txtYourName.Text + "là người chiến thắng";

                Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), temp2);
                chatBox.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                chatBox.Items.Add(Messege);
            }
            if (banco.End == Player.Online && BanCo.Option.WhoPlayWith == Player.Online)
            {
                string temp2 = MainWindow.name + "là người chiến thắng";

                Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), temp2);
                chatBox.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                chatBox.Items.Add(Messege);
            }
            if (banco.End == Player.Human && BanCo.Option.WhoPlayWith == Player.MayOnline)
            {
                string temp2 = MainWindow.name + "là người chiến thắng";

                Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), temp2);
                chatBox.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                chatBox.Items.Add(Messege);
            }
           
     
           
        }
示例#13
0
        private void banco_LoseEvent()
        {
            if (BanCo.Option.WhoPlayWith == Player.Com && banco.End==Player.Com)
            {
                Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), "Cố lên nhé");
                chatBox.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                chatBox.Items.Add(Messege);
            }
            if (banco.End == Player.Com && BanCo.Option.WhoPlayWith == Player.MayOnline)
            {
                string temp2 = txtYourName.Text + "là người chiến thắng";

                Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), temp2);
                chatBox.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                chatBox.Items.Add(Messege);
            }

        }
示例#14
0
         private void txt_change(object sender, TextChangedEventArgs e)
        {
            if(BanCo.currPlayer==Player.Online && BanCo.end==Player.None)
            {
                BanCo.board[BanCo.rows, BanCo.columns] = BanCo.currPlayer;//Lưu loại cờ vừa đánh vào mảng
                BanCo.DrawDataBoard(BanCo.rows, BanCo.columns, true, true);
                BanCo.end = BanCo.CheckEnd(BanCo.rows, BanCo.columns);//Kiểm tra xem trận đấu kết thúc chưa

                if (BanCo.end == Player.Online)//Nếu người chơi 2 thắng
                {
                    BanCo.OnWin();//Khai báo sư kiện Win
                    BanCo.OWinorLose();//Hiển thị 5 ô Win.
                    Messege Messege = new Messege("Server", DateTime.Now.ToString("hh:mm:ss tt"), name+ " là người thắng");
                    chatBox.VerticalAlignment = System.Windows.VerticalAlignment.Top;
                    chatBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                    chatBox.Items.Add(Messege);
                    btnonline.Content = "New game";
                    newgame1 = true;
                }
                else
                {
                    BanCo.currPlayer = Player.Human;//Thiết lập lại lượt chơi
                    BanCo.OnComDanhXong();// Khai báo sự kiện người chơi 2 đánh xong
                }
                    
               

            }
        }