Beispiel #1
0
        //Contructors
        public BanCo(MainWindow frm, Grid grd)
        {
            Option = new TuyChon();
            OWin = new cls5OWin();
            row = column = 12;
            currPlayer = Player.None;
            end = Player.None;
            frmParent = frm;
            grdBanCo = grd;
            board = new Player[row, column];
            ResetBoard();
            eBoard = new LuongGia(this);

          
            grdBanCo.MouseDown += new System.Windows.Input.MouseButtonEventHandler(grdBanCo_MouseDown);
            worker.DoWork += wait;
            worker.RunWorkerCompleted +=maydanh;
        }
Beispiel #2
0
 //Contructors
 public BanCo(MainWindow frm, Grid grd)
 {
     Option = new Chon();
     OWin = new _5OWin();
     row = column = 12;
     board = new Player[row, column];
     ResetBoard();
     eBoard = new LuongGia(this);
     currPlayer = Player.None;
     end = Player.None;
     frmParent = frm;
     grdBanCo = grd;           
     ddau = new DanhDau();
     Createddau();
     grdBanCo.Children.Add(ddau);
     grdBanCo.MouseDown += new System.Windows.Input.MouseButtonEventHandler(grdBanCo_MouseDown);
     worker.DoWork += wait;
     worker.RunWorkerCompleted += danh;
 }
Beispiel #3
0
 //Hàm lấy đối thủ của người chơi hiện tại
 public static Player DoiNgich(Player cur)
 {
     if (cur == Player.Com) return Player.Human;
     if (cur == Player.Human) return Player.Com;
     return Player.None;
 }
Beispiel #4
0
        //Hàm lượng giá thế cờ
        public static void LuongGia(Player player)
        {
            int cntHuman = 0, cntCom = 0;//Biến đếm Human,Com
            #region Luong gia cho hang
            for (int i = 0; i < row; i++)
            {
                for (int j = 0; j < column - 4; j++)
                {
                    //Khởi tạo biến đếm
                    cntHuman = cntCom = 0;
                    //Đếm số lượng con cờ trên 5 ô kế tiếp của 1 hàng
                    for (int k = 0; k < 5; k++)
                    {
                        if (board[i, j + k] == Player.Human) cntHuman++;
                        if (board[i, j + k] == Player.Com) cntCom++;
                    }
                    //Lượng giá
                    //Nếu 5 ô kế tiếp chỉ có 1 loại cờ (hoặc là Human,hoặc la Com)
                    if (cntHuman * cntCom == 0 && cntHuman != cntCom)
                    {
                        //Gán giá trị cho 5 ô kế tiếp của 1 hàng
                        for (int k = 0; k < 5; k++)
                        {
                            //Nếu ô đó chưa có quân đi
                            if (board[i, j + k] == Player.None)
                            {
                                //Nếu trong 5 ô đó chỉ tồn tại cờ của Human
                                if (cntCom == 0)
                                {
                                    //Nếu đối tượng lượng giá là Com
                                    if (player == Player.Com)
                                    {
                                        //Vì đối tượng người chơi là Com mà trong 5 ô này chỉ có Human
                                        //nên ta sẽ cộng thêm điểm phòng thủ cho Com
                                        eBoard.GiaTri[i, j + k] += PhongThu[cntHuman];
                                    }
                                    //Ngược lại cộng điểm phòng thủ cho Human
                                    else
                                    {
                                        eBoard.GiaTri[i, j + k] += TanCong[cntHuman];
                                    }
                                    //Nếu chơi theo luật Việt Nam
                                    if (Option.GamePlay == LuatChoi.Vietnamese)
                                        //Xét trường hợp chặn 2 đầu
                                        //Nếu chận 2 đầu thì gán giá trị cho các ô đó bằng 0
                                        if (j - 1 >= 0 && j + 5 <= column - 1 && board[i, j - 1] == Player.Com && board[i, j + 5] == Player.Com)
                                        {
                                            eBoard.GiaTri[i, j + k] = 0;
                                        }

                                }
                                //Tương tự như trên
                                if (cntHuman == 0) //Nếu chỉ tồn tại Com
                                {
                                    if (player == Player.Human) //Nếu người chơi là Người
                                    {
                                        eBoard.GiaTri[i, j + k] += PhongThu[cntCom];
                                    }
                                    else
                                    {
                                        eBoard.GiaTri[i, j + k] += TanCong[cntCom];
                                    }
                                    //Trường hợp chặn 2 đầu
                                    if (Option.GamePlay == LuatChoi.Vietnamese)
                                        if (j - 1 >= 0 && j + 5 <= column - 1 && board[i, j - 1] == Player.Human && board[i, j + 5] == Player.Human)
                                        {
                                            eBoard.GiaTri[i, j + k] = 0;
                                        }

                                }
                                if ((j + k - 1 > 0) && (j + k + 1 <= column - 1) && (cntHuman == 4 || cntCom == 4)
                                   && (board[i, j + k - 1] == Player.None || board[i, j + k + 1] == Player.None))
                                {
                                    eBoard.GiaTri[i, j + k] *= 3;
                                }
                            }
                        }
                    }
                }
            }
            #endregion
            //Tương tự như lượng giá cho hàng
            #region Luong gia cho cot
            for (int i = 0; i < row - 4; i++)
            {
                for (int j = 0; j < column; j++)
                {
                    cntHuman = cntCom = 0;
                    for (int k = 0; k < 5; k++)
                    {
                        if (board[i + k, j] == Player.Human) cntHuman++;
                        if (board[i + k, j] == Player.Com) cntCom++;
                    }
                    if (cntHuman * cntCom == 0 && cntCom != cntHuman)
                    {
                        for (int k = 0; k < 5; k++)
                        {
                            if (board[i + k, j] == Player.None)
                            {
                                if (cntCom == 0)
                                {
                                    if (player == Player.Com) eBoard.GiaTri[i + k, j] += PhongThu[cntHuman];
                                    else eBoard.GiaTri[i + k, j] += TanCong[cntHuman];
                                    // Truong hop bi chan 2 dau.
                                    if ((i - 1) >= 0 && (i + 5) <= row - 1 && board[i - 1, j] == Player.Com && board[i + 5, j] == Player.Com)
                                    {
                                        eBoard.GiaTri[i + k, j] = 0;
                                    }
                                }
                                if (cntHuman == 0)
                                {
                                    if (player == Player.Human) eBoard.GiaTri[i + k, j] += PhongThu[cntCom];
                                    else eBoard.GiaTri[i + k, j] += TanCong[cntCom];
                                     //Truong hop bi chan 2 dau.
                                    if (Option.GamePlay == LuatChoi.Vietnamese)
                                        if (i - 1 >= 0 && i + 5 <= row - 1 && board[i - 1, j] == Player.Human && board[i + 5, j] == Player.Human)
                                            eBoard.GiaTri[i + k, j] = 0;
                                }
                                if ((i + k - 1) >= 0 && (i + k + 1) <= row - 1 && (cntHuman == 4 || cntCom == 4)
                                    && (board[i + k - 1, j] == Player.None || board[i + k + 1, j] == Player.None))
                                {
                                    eBoard.GiaTri[i + k, j] *= 3;
                                }
                            }
                        }
                    }
                }
            }
            #endregion
            //Tương tự như lượng giá cho hàng
            #region  Luong gia tren duong cheo chinh (\)
            for (int i = 0; i < row - 4; i++)
            {
                for (int j = 0; j < column - 4; j++)
                {
                    cntHuman = cntCom = 0;
                    for (int k = 0; k < 5; k++)
                    {
                        if (board[i + k, j + k] == Player.Human) cntHuman++;
                        if (board[i + k, j + k] == Player.Com) cntCom++;
                    }
                    if (cntHuman * cntCom == 0 && cntCom != cntHuman)
                    {
                        for (int k = 0; k < 5; k++)
                        {
                            if (board[i + k, j + k] == Player.None)
                            {
                                if (cntCom == 0)
                                {
                                    if (player == Player.Com) eBoard.GiaTri[i + k, j + k] += PhongThu[cntHuman];
                                    else eBoard.GiaTri[i + k, j + k] += TanCong[cntHuman];
                                    // Truong hop bi chan 2 dau.
                                    if (Option.GamePlay == LuatChoi.Vietnamese)
                                        if (i - 1 >= 0 && j - 1 >= 0
                                            && i + 5 <= row - 1 && j + 5 <= column - 1
                                            && board[i - 1, j - 1] == Player.Com && board[i + 5, j + 5] == Player.Com)
                                            eBoard.GiaTri[i + k, j + k] = 0;
                                }
                                if (cntHuman == 0)
                                {
                                    if (player == Player.Human) eBoard.GiaTri[i + k, j + k] += PhongThu[cntCom];
                                    else eBoard.GiaTri[i + k, j + k] += TanCong[cntCom];
                                    // Truong hop bi chan 2 dau.
                                    if (Option.GamePlay == LuatChoi.Vietnamese)
                                        if ((i - 1) >= 0 && j - 1 >= 0
                                            && i + 5 <= row - 1 && j + 5 <= column - 1
                                            && board[i - 1, j - 1] == Player.Human && board[i + 5, j + 5] == Player.Human)
                                        {
                                            eBoard.GiaTri[i + k, j + k] = 0;
                                        }
                                }
                                if ((i + k - 1) >= 0 && (j + k - 1) >= 0 && (i + k + 1) <= row - 1 && (j + k + 1) <= column - 1 && (cntHuman == 4 || cntCom == 4)
                                    && (board[i + k - 1, j + k - 1] == Player.None || board[i + k + 1, j + k + 1] == Player.None))
                                {
                                    eBoard.GiaTri[i + k, j + k] *= 3;
                                }
                            }
                        }
                    }
                }
            }
            #endregion
            //Tương tự như lượng giá cho hàng
            #region Luong gia tren duong cheo phu (/)
            for (int i = 4; i < row - 4; i++)
            {
                for (int j = 0; j < column - 4; j++)
                {
                    cntCom = 0; cntHuman = 0;
                    for (int k = 0; k < 5; k++)
                    {
                        if (board[i - k, j + k] == Player.Human) cntHuman++;
                        if (board[i - k, j + k] == Player.Com) cntCom++;
                    }
                    if (cntHuman * cntCom == 0 && cntHuman != cntCom)
                    {
                        for (int k = 0; k < 5; k++)
                        {
                            if (board[i - k, j + k] == Player.None)
                            {
                                if (cntCom == 0)
                                {
                                    if (player == Player.Com) eBoard.GiaTri[i - k, j + k] += PhongThu[cntHuman];
                                    else eBoard.GiaTri[i - k, j + k] += TanCong[cntHuman];
                                    // Truong hop bi chan 2 dau.
                                    if (i + 1 <= row - 1 && j - 1 >= 0 && i - 5 >= 0 && j + 5 <= column - 1 && board[i + 1, j - 1] == Player.Com && board[i - 5, j + 5] == Player.Com)
                                    {
                                        eBoard.GiaTri[i - k, j + k] = 0;
                                    }
                                }
                                if (cntHuman == 0)
                                {
                                    if (player == Player.Human) eBoard.GiaTri[i - k, j + k] += PhongThu[cntCom];
                                    else eBoard.GiaTri[i - k, j + k] += TanCong[cntCom];
                                    // Truong hop bi chan 2 dau.
                                    if (Option.GamePlay == LuatChoi.Vietnamese)
                                        if (i + 1 <= row - 1 && j - 1 >= 0 && i - 5 >= 0 && j + 5 <= column - 1 && board[i + 1, j - 1] == Player.Human && board[i - 5, j + 5] == Player.Human)
                                        {
                                            eBoard.GiaTri[i - k, j + k] = 0;
                                        }
                                }
                                if ((i - k + 1) <= row - 1 && (j + k - 1) >= 0
                                    && (i - k - 1) >= 0 && (j + k + 1) <= column - 1
                                    && (cntHuman == 4 || cntCom == 4)
                                    && (board[i - k + 1, j + k - 1] == Player.None || board[i - k - 1, j + k + 1] == Player.None))
                                {
                                    eBoard.GiaTri[i - k, j + k] *= 3;
                                }
                            }
                        }
                    }
                }
            }
            #endregion
        }
Beispiel #5
0
        //Hàm đánh cờ
        public void grdBanCo_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            System.GC.Collect();//Thu gôm rác
            if (Option.WhoPlayWith == Player.Com)//Nếu chọn kiểu chơi đánh với máy
            {
                Point toado = e.GetPosition(grdBanCo); //Lấy tọa độ chuột
                //Xử lý tọa độ
                int cl = ((int)toado.X / length);
                int rw = ((int)toado.Y / length);

         
                if (board[rw, cl] == Player.None) //Nếu ô bấm chưa có cờ
                {
                    if (currPlayer == Player.Human && end == Player.None)//Nếu lượt đi là người và trận đấu chưa kết thúc
                    {
                        board[rw, cl] = currPlayer;//Lưu loại cờ vừa đánh vào mảng
                        DrawDataBoard(rw, cl, true, true);//Vẽ con cờ theo lượt chơi
                        end = CheckEnd(rw, cl);//Kiểm tra xem trận đấu kết thúc chưa
                        if (end == Player.Human)//Nếu người thắng cuộc là người
                        {
                            OnWin();//Khai báo sự kiện Win
                            OWinorLose();//Hiển thị 5 ô Win.
                        }
                        else if (end == Player.None) //Nếu trận đấu chưa kết thúc
                        {
                            currPlayer = Player.Com;//Thiết lập lại lượt chơi
                            OnHumanDanhXong(); // Khai báo sự kiện người đánh xong
                        }
                    }
                    try
                    {
                        worker.RunWorkerAsync();
                    }
                    catch
                    {

                    }
                  

                }
            }
            else if (Option.WhoPlayWith == Player.Human) //Nếu chọn kiểu chơi 2 người đánh với nhau
            {
                //Player.Com sẽ đóng vai trò người chơi thứ 2
                Point toado = e.GetPosition(grdBanCo);//Lấy thông tin tọa độ chuột
                //Xử lý tọa độ
                int cl = ((int)toado.X / length);
                int rw = ((int)toado.Y / length);
                if (board[rw, cl] == Player.None)//Nếu ô bấm chưa có cờ
                {
                    if (currPlayer == Player.Human && end == Player.None)//Nếu lượt đi là người và trận đấu chưa kết thúc
                    {
                        board[rw, cl] = currPlayer;//Lưu loại cờ vừa đánh vào mảng
                        DrawDataBoard(rw, cl, true, true);//Vẽ con cờ theo lượt chơi
                        end = CheckEnd(rw, cl);//Kiểm tra xem trận đấu kết thúc chưa
                        if (end == Player.Human)//Nếu người chơi 1 thắng
                        {
                            currPlayer = Player.Human; //Thiết lập lại lượt chơi
                            OnWin();//Khai báo sư kiện Win
                            OWinorLose();//Hiển thị 5 ô Win.
                        }
                        else
                        {
                            currPlayer = Player.Com;//Thiết lập lại lượt chơi
                            OnHumanDanhXong();// Khai báo sự kiện người chơi 1 đánh xong
                        }
                    }
                    else if (currPlayer == Player.Com && end == Player.None)
                    {
                        board[rw, cl] = currPlayer;//Lưu loại cờ vừa đánh vào mảng
                        DrawDataBoard(rw, cl, true, true);//Vẽ con cờ theo lượt chơi
                        end = CheckEnd(rw, cl);//Kiểm tra xem trận đấu kết thúc chưa
                        if (end == Player.Com)//Nếu người chơi 2 thắng
                        {
                            OnWin();//Khai báo sư kiện Win
                            OWinorLose();//Hiển thị 5 ô Win.
                        }
                        else
                        {
                            currPlayer = Player.Human;//Thiết lập lại lượt chơi
                            OnComDanhXong();// Khai báo sự kiện người chơi 2 đánh xong
                        }
                    }
                }
            }
            else if (Option.WhoPlayWith == Player.Online) // chọn người chơi online
            {
                Point toado = e.GetPosition(grdBanCo); //Lấy tọa độ chuột
                //Xử lý tọa độ
                int cl = ((int)toado.X / length);
                int rw = ((int)toado.Y / length);

                if (board[rw, cl] == Player.None) //Nếu ô bấm chưa có cờ
                {
                    if (currPlayer == Player.Human && end == Player.None)// /Nếu lượt đi là mình và trận đấu chưa kết thúc
                    {
                        connect.rw = rw;
                        connect.cl = cl;
                        connect.guitoado(MainWindow.socket, rw, cl);
                        board[rw, cl] = currPlayer;//Lưu loại cờ vừa đánh vào mảng
                        DrawDataBoard(rw, cl, true, true);//Vẽ con cờ theo lượt chơi
                        end = CheckEnd(rw, cl);//Kiểm tra xem trận đấu kết thúc chưa
                        if (end == Player.Human)//Nếu người thắng cuộc là mình
                        {
                            OnWin();//Khai báo sự kiện Win
                            OWinorLose();//Hiển thị 5 ô Win.
                            MainWindow.newgame1 = true;
                        }
                        else if (end == Player.None) //Nếu trận đấu chưa kết thúc
                        {
                            currPlayer = Player.Online;//Thiết lập lại lượt chơi
                            OnHumanDanhXong(); // Khai báo sự kiện người đánh xong
                        }


                    }
                }
            }
        }
Beispiel #6
0
        public void danh(object sender, RunWorkerCompletedEventArgs e)
        {
            if (currPlayer == Player.Com && end == Player.None)//Nếu lượt đi là máy và trận đấu chưa kết thúc
            {
                //Tìm đường đi cho máy
                eBoard.ResetBoard();
                LuongGia(Player.Com);//Lượng giá bàn cờ cho máy
                node = eBoard.GetMaxNode();//lưu vị trí máy sẽ đánh
                int r, c;
                r = node.Row; c = node.Column;
                board[r, c] = currPlayer; //Lưu loại cờ vừa đánh vào mảng
                DrawDataBoard(r, c, true, true); //Vẽ con cờ theo lượt chơi
                end = CheckEnd(r, c);//Kiểm tra xem trận đấu kết thúc chưa

                if (end == Player.Com)//Nếu máy thắng
                {
                    OnLose();//Khai báo sư kiện Lose
                    OWinorLose();//Hiển thị 5 ô Lose.
                }
                else if (end == Player.None)
                {
                    currPlayer = Player.Human;//Thiết lập lại lượt chơi
                    OnComDanhXong();// Khai báo sự kiện người đánh xong
                }
            }
        }
Beispiel #7
0
 public static void DiNgauNhien()
 {
     if (currPlayer == Player.Com)
     {
         board[row / 2, column / 2] = currPlayer;
         DrawDataBoard(row / 2, column / 2, true, true);
         MainWindow.rowngaunhien = row / 2;
         MainWindow.colngaunhien = column / 2;
         currPlayer = Player.Human;
         OnComDanhXong();//Khai báo sự kiện khi máy đánh xong
     }
 }
Beispiel #8
0
        //Bắt đầu lại trò chơi mới
        public void PlayAgain()
        {
            OWin = new _5OWin();

            grdBanCo.Children.Clear();//xóa hết tất cả các con cờ trên bàn cờ
            grdBanCo.Children.Add(ddau);//tạo hình vuong( tỏa tỏa)
            ResetBoard();// tất cả các ô cờ chưa ai đánh hết
            this.DrawGomokuBoard();//vẻ bàn cờ lên
            if (Option.WhoPlayWith == Player.Com)
            {
                if (end == Player.None)
                {
                    currPlayer = Player.Com;                  
                    DiNgauNhien();
                }
            }
            else
            {
                if (end == Player.None)
                {
                    if (currPlayer == Player.Human)
                    {
                        currPlayer = Player.Com;
                    }
                    else if (currPlayer == Player.Com)
                    {
                        currPlayer = Player.Human;
                    }
                }
            }
            end = Player.None;
        }
Beispiel #9
0
 //Bắt đầu trò chơi mới
 public void NewGame()
 {
     currPlayer = Option.LuotChoi;//Lấy thông tin lượt chơi
     if (Option.WhoPlayWith == Player.Com)//Nếu chọn kiểu chơi với máy
     {
         if (currPlayer == Player.Com)//Nếu lược đi là máy
         {
             DiNgauNhien();
         }
     }
 }
        private void SkeletonsReady(object sender, SkeletonFrameReadyEventArgs e)
        {
            if (StatInit == 0)
            {
                for (int i = 0; i < StatusArrayLen; i++)
                {
                    StatusArray[i] = 0;
                }
                StatInit = 1;
            }
            using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
            {
                if (skeletonFrame != null)
                {
                    int skeletonSlot = 0;

                    if ((this.skeletonData == null) || (this.skeletonData.Length != skeletonFrame.SkeletonArrayLength))
                    {
                        this.skeletonData = new Skeleton[skeletonFrame.SkeletonArrayLength];
                    }

                    skeletonFrame.CopySkeletonDataTo(this.skeletonData);

                    foreach (Skeleton skeleton in this.skeletonData)
                    {
                        if (SkeletonTrackingState.Tracked == skeleton.TrackingState)
                        {
                            Player player;
                            if (this.players.ContainsKey(skeletonSlot))
                            {
                                player = this.players[skeletonSlot];
                            }
                            else
                            {
                                player = new Player(skeletonSlot);
                                player.SetBounds(this.playerBounds);
                                this.players.Add(skeletonSlot, player);
                            }

                            player.LastUpdated = DateTime.Now;

                            // Update player's bone and joint positions
                            if (skeleton.Joints.Count > 0)
                            {
                                player.IsAlive = true;

                                // Head, hands, feet (hit testing happens in order here)
                                player.UpdateJointPosition(skeleton.Joints, JointType.Head);
                                player.UpdateJointPosition(skeleton.Joints, JointType.HandLeft);
                                player.UpdateJointPosition(skeleton.Joints, JointType.HandRight);
                                player.UpdateJointPosition(skeleton.Joints, JointType.FootLeft);
                                player.UpdateJointPosition(skeleton.Joints, JointType.FootRight);

                                // Hands and arms
                                player.UpdateBonePosition(skeleton.Joints, JointType.HandRight, JointType.WristRight);
                                player.UpdateBonePosition(skeleton.Joints, JointType.WristRight, JointType.ElbowRight);
                                player.UpdateBonePosition(skeleton.Joints, JointType.ElbowRight, JointType.ShoulderRight);

                                player.UpdateBonePosition(skeleton.Joints, JointType.HandLeft, JointType.WristLeft);
                                player.UpdateBonePosition(skeleton.Joints, JointType.WristLeft, JointType.ElbowLeft);
                                player.UpdateBonePosition(skeleton.Joints, JointType.ElbowLeft, JointType.ShoulderLeft);

                                // Head and Shoulders
                                player.UpdateBonePosition(skeleton.Joints, JointType.ShoulderCenter, JointType.Head);
                                player.UpdateBonePosition(skeleton.Joints, JointType.ShoulderLeft, JointType.ShoulderCenter);
                                player.UpdateBonePosition(skeleton.Joints, JointType.ShoulderCenter, JointType.ShoulderRight);

                                // Legs
                                player.UpdateBonePosition(skeleton.Joints, JointType.HipLeft, JointType.KneeLeft);
                                player.UpdateBonePosition(skeleton.Joints, JointType.KneeLeft, JointType.AnkleLeft);
                                player.UpdateBonePosition(skeleton.Joints, JointType.AnkleLeft, JointType.FootLeft);

                                player.UpdateBonePosition(skeleton.Joints, JointType.HipRight, JointType.KneeRight);
                                player.UpdateBonePosition(skeleton.Joints, JointType.KneeRight, JointType.AnkleRight);
                                player.UpdateBonePosition(skeleton.Joints, JointType.AnkleRight, JointType.FootRight);

                                player.UpdateBonePosition(skeleton.Joints, JointType.HipLeft, JointType.HipCenter);
                                player.UpdateBonePosition(skeleton.Joints, JointType.HipCenter, JointType.HipRight);

                                // Spine
                                player.UpdateBonePosition(skeleton.Joints, JointType.HipCenter, JointType.ShoulderCenter);
                                //countPlayer = skeleton.Joints.Count;

                                //rrr
                                playfield.Children.Clear();
                                player.Draw(playfield.Children);
                                
                                skeletonStatus= GetSkeletonStatus(skeleton);
                                StatusArray[countAction%StatusArrayLen] = skeletonStatus;

                                if (skeletonStatus == WALK)
                                {
                                    for (int i = 0; i < StatusArrayLen; i++)
                                        if (StatusArray[i] == STAND)
                                            StatusArray[i] = WALK;
                                }
                                skeletonStatus = GetCommon(StatusArray);



                                switch (skeletonStatus)
                                {
                                    case STAND:
                                        this.StatusLabel.Content = "Standing";
                                        break;
                                    case SIT:
                                        this.StatusLabel.Content = "Sitting";
                                        break;
                                    case LIEDOWN:
                                        this.StatusLabel.Content = "Lying Down";
                                        break;
                                    case WALK:
                                        this.StatusLabel.Content = "Walking";
                                        break;
                                    default:
                                        this.StatusLabel.Content = "No Gesture";
                                        break;
                                }

                                if (skeletonStatus == SIT)
                                    ResetPosition();
                                

                                if ( countAction%20 == 0 && Done == 0 && skeletonStatus == WALK)
                                {
                                    double t = CaculateDeg(skeleton.Joints[JointType.ElbowRight].Position, skeleton.Joints[JointType.WristRight].Position);
                                    if (Math.Abs(t - 270) < 15)
                                    {
                                        ResponsetoDownKey();
                                    }
                                    else if (Math.Abs(t - 90) < 15)
                                    {
                                        ResponsetoUpKey();
                                    }
                                    else if (Math.Abs(t) < 15 || Math.Abs(t-360) < 15)
                                    {
                                        ResponsetoRightKey();
                                    }
                                    else if (Math.Abs(t - 180) < 15)
                                    {
                                        ResponsetoLeftKey();
                                    }

                                }
                                countAction++;
                                //rrr
                            }
                            
                        }

                        skeletonSlot++;
                    }
                }
            }
            playfield.Children.Clear();
            foreach (var player in this.players)
            {
                player.Value.Draw(playfield.Children);
            }
        }
Beispiel #11
0
        //Bắt đầu lại trò chơi mới
        public void PlayAgain()
        {
            OWin = new cls5OWin();

            grdBanCo.Children.Clear();
            grdBanCo.Children.Add(hv);
            ResetBoard();
            this.DrawGomokuBoard();
            if (Option.WhoPlayWith == Player.Com)
            {
                if (end == Player.None)
                {
                    currPlayer = Player.Com;

                }
                if (currPlayer == Player.Com && Option.WhoPlayWith == Player.Com)
                {
                    DiNgauNhien();
                }
            }
            else
            {
                if (end == Player.None)
                {
                    if (currPlayer == Player.Human)
                    {
                        currPlayer = Player.Com;

                    }
                    else if (currPlayer == Player.Com)
                    {
                        currPlayer = Player.Human;

                    }
                }
            }
            end = Player.None;
        }