/// <summary> /// /// </summary> /// <param name="networkStream"></param> /// <param name="msgType"> pawn_move �����ƶ� who_first ������� chat_msg ������Ϣ</param> /// <param name="id"></param> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> public static void SendMessage(NetworkStream networkStream, MessageEntity messageEntity) { try { buffer = Encoding.Unicode.GetBytes(messageEntity.GetMsgType() + "+" + messageEntity.GetMsgContent()); lock (networkStream) { networkStream.Write(buffer, 0, buffer.Length); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
// ������ private void pictureBox_Rma_MouseClick(object sender, MouseEventArgs e) { if (hold == false && isMe) { hold = true; _p = pictureBox_Rma.Location; _x = col_pixel_to_block[_p.X]; _y = row_pixel_to_block[_p.Y]; p = Cursor.Position; } if (hold == true && isMove == true) { hold = false; isMove = false; Point point = Rules.Locate(this, pictureBox_Rma.Location); x = col_pixel_to_block[point.X]; y = row_pixel_to_block[point.Y]; Point RjiangPoint = Rules.Locate(this, pictureBox_Rjiang.Location); int Rjiang_x = col_pixel_to_block[RjiangPoint.X]; int Rjiang_y = row_pixel_to_block[RjiangPoint.Y]; Point BjiangPoint = Rules.Locate(this, pictureBox_Bjiang.Location); int Bjiang_x = col_pixel_to_block[BjiangPoint.X]; int Bjiang_y = row_pixel_to_block[BjiangPoint.Y]; if (Rules.CanMove(this, "ma", _x, _y, x, y)) { Rules.DoMove(this, pictureBox_Rma, _x, _y, x, y); if (Rules.CheckJiang(this, Rjiang_x, Rjiang_y, Bjiang_x, Bjiang_y)) { MessageEntity messageEntity = new MessageEntity("pawn_move", "Rma", _x, _y, x, y); Rules.SendMessage(networkStream, messageEntity); isMe = false; } else { Rules.DoMove(this, pictureBox_Rma, x, y, _x, _y); } } else { Rules.DoMove(this, pictureBox_Rma, _x, _y, _x, _y); } } }