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; }
public QiZi(QiSe qs, Rectangle r, Graphics g, int rp) { this.qs = qs; rect = r; gp = g; rectPix = rp; }
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; } } } } }
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); }
//接收线程函数 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; } } } } }
//局域网游戏 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; }