Example #1
0
File: QiZi.cs Project: muupu/GoMoku
        private int rectPix; //棋子大小

        #endregion Fields

        #region Constructors

        public QiZi(QiSe qs, Rectangle r, Graphics g, int rp)
        {
            this.qs = qs;
            rect = r;
            gp = g;
            rectPix = rp;
        }
Example #2
0
 public QiZi(QiSe qs, Rectangle r, Graphics g, int rp)
 {
     this.qs = qs;
     rect    = r;
     gp      = g;
     rectPix = rp;
 }
Example #3
0
 public void ThreadProc()//接收线程函数
 {
     while (bt)
     {
         if (start)
         {
             if (isServer)
             {
                 QiZi qz = localnet.Recv();
                 if (qz != null)
                 {
                     int i = qz.Rect.X / rectPix;
                     int j = qz.Rect.Y / rectPix;
                     QzArr[i, j] = qz;
                     qz.Paint();
                     if (ShuYin())
                     {
                         bt = false;
                         localnet.Close();
                         shu = true;
                     }
                     this.turn = QiSe.Bai;
                 }
             }
             else
             {
                 QiZi qz = localnet.Recv();
                 if (qz != null)
                 {
                     int i = qz.Rect.X / rectPix;
                     int j = qz.Rect.Y / rectPix;
                     QzArr[i, j] = qz;
                     qz.Paint();
                     if (ShuYin())
                     {
                         bt = false;
                         localnet.Close();
                         shu = true;
                     }
                     this.turn = QiSe.Hei;
                 }
             }
         }
     }
 }
Example #4
0
        public bool LocalnetXiaQi(int x, int y)//局域网游戏
        {
            if (isServer && turn == QiSe.Bai)
            {
                if (qzArr[x, y].Qs == QiSe.Null)
                {
                    qzArr[x, y].Qs = turn;
                    qzArr[x, y].Paint();
                    q1 = qzArr[x, y];
                    if (ShuYin())
                    {
                        localnet.Send(QzArr[x, y]);
                        this.turn = QiSe.Hei;
                        localnet.Close();
                        return(true);
                    }

                    localnet.Send(QzArr[x, y]);
                    this.turn = QiSe.Hei;
                }
            }

            if (!isServer && turn == QiSe.Hei)
            {
                if (qzArr[x, y].Qs == QiSe.Null)
                {
                    qzArr[x, y].Qs = turn;
                    qzArr[x, y].Paint();
                    q1 = qzArr[x, y];
                    if (ShuYin())
                    {
                        localnet.Send(QzArr[x, y]);
                        this.turn = QiSe.Hei;
                        localnet.Close();
                        return(true);
                    }
                    localnet.Send(QzArr[x, y]);
                    this.turn = QiSe.Bai;
                }
            }

            return(false);
        }
Example #5
0
        //接收线程函数
        public void ThreadProc()
        {
            while (bt)
            {
                if (start)
                {
                    if (isServer)
                    {
                        QiZi qz = localnet.Recv();
                        if (qz != null)
                        {
                            int i = qz.Rect.X / rectPix;
                            int j = qz.Rect.Y / rectPix;
                            QzArr[i, j] = qz;
                            qz.Paint();
                            if (ShuYin())
                            {
                                bt = false;
                                localnet.Close();
                                shu = true;
                            }
                            this.turn = QiSe.Bai;
                        }

                    }
                    else
                    {

                        QiZi qz = localnet.Recv();
                        if (qz != null)
                        {
                            int i = qz.Rect.X / rectPix;
                            int j = qz.Rect.Y / rectPix;
                            QzArr[i, j] = qz;
                            qz.Paint();
                            if (ShuYin())
                            {
                                bt = false;
                                localnet.Close();
                                shu = true;
                            }
                            this.turn = QiSe.Hei;
                        }

                    }
                }
            }
        }
Example #6
0
        //局域网游戏
        public bool LocalnetXiaQi(int x, int y)
        {
            if (isServer && turn == QiSe.Bai)
            {
                if (qzArr[x, y].Qs == QiSe.Null)
                {
                    qzArr[x, y].Qs = turn;
                    qzArr[x, y].Paint();
                    q1 = qzArr[x, y];
                    if (ShuYin())
                    {
                        localnet.Send(QzArr[x, y]);
                        this.turn = QiSe.Hei;
                        localnet.Close();
                        return true;
                    }

                    localnet.Send(QzArr[x, y]);
                    this.turn = QiSe.Hei;
                }
            }

            if (!isServer && turn == QiSe.Hei)
            {
                if (qzArr[x, y].Qs == QiSe.Null)
                {
                    qzArr[x, y].Qs = turn;
                    qzArr[x, y].Paint();
                    q1 = qzArr[x, y];
                    if (ShuYin())
                    {
                        localnet.Send(QzArr[x, y]);
                        this.turn = QiSe.Hei;
                        localnet.Close();
                        return true;
                    }
                    localnet.Send(QzArr[x, y]);
                    this.turn = QiSe.Bai;
                }
            }

            return false;
        }