public Revive(int x, int y, STONE s, int seq) { this.X = x; this.Y = y; this.Stone = s; this.Seq = seq; }
//오목 전송 void OnSendData2(int x, int y, STONE stone) { // 서버가 대기중인지 확인한다. if (!mainSock.IsBound) { MsgBoxHelper.Warn("서버가 실행되고 있지 않습니다!"); return; } String STONE = stone.ToString(); Console.WriteLine("x : " + x); Console.WriteLine("Y : " + y); Console.WriteLine("색깔 1-검정, 2-흰돌 : " + stone); string turn = "myturn"; byte[] bDts = Encoding.UTF8.GetBytes("1:" + x + ':' + y + ':' + STONE + ':' + turn + ':'); //클라이언트에 전송한다. try { clientSokect.Send(bDts); } catch { // 오류 발생하면 전송 취소하고 리스트에서 삭제한다. try { clientSokect.Dispose(); } catch { } } }
// 생성자: public, 리턴 타입 없고, //Class와 같은 이름인 메서드 public Revive(int x, int y, STONE st, int seq) { X = x; Y = y; Stone = st; Seq = seq; }
// 생성자: public, 리턴 타입 없고, // Class와 같은 이름인 메서드 public Revive(int x, int y, STONE st, int seq) { x = x; y = y; Stone = st; seq = seq; }
private void Chatting_Recv(object sender, DoWorkEventArgs e) { while (true) { if (!bConnect) { continue; } int strLen = hClntSock.Receive(buf); if ((char)buf[0] == 'M') { string chatMessage = Encoding.Default.GetString(buf, 5, strLen - 5).Trim(); int id = BitConverter.ToUInt16(buf, 1); listBox1.Items.Add("[" + id.ToString() + "]: " + chatMessage); //Chatting highlight Function listBox1.SelectedIndex = listBox1.Items.Count - 1; } else if ((char)buf[1] == 'P') { OtherTurn(); } else if ((char)buf[0] == 'J') { if ((char)buf[1] == 'W') { stone = STONE.WHITE; } else if ((char)buf[1] == 'B') { stone = STONE.BLACK; } hClntSock.Send(buf); // } else if ((char)buf[0] == 'S') { MessageBox.Show("Game Start!"); if (stone == STONE.BLACK) { bTurn = true; } else if (stone == STONE.WHITE) { bTurn = false; } } } }
// 복기 리스트에 있는 내용을 하나씩 그려준다 private void DrawAStone(Revive item) { int x = item.X; int y = item.Y; STONE s = item.stone; int seq = item.seq; // 바둑판[x,y] 에 돌을 그린다 Rectangle r = new Rectangle( margin + 눈Size * x - 돌Size / 2, margin + 눈Size * y - 돌Size / 2, 돌Size, 돌Size); // 검은돌 차례 if (s == STONE.black) { if (imageFlag == false) { g.FillEllipse(bBrush, r); } else { Bitmap bmp = new Bitmap("../../img/black.png"); g.DrawImage(bmp, r); } DrawStoneSequence(seq, Brushes.White, r); 바둑판[x, y] = STONE.black; } else { if (imageFlag == false) { g.FillEllipse(wBrush, r); } else { Bitmap bmp = new Bitmap("../../img/white.png"); g.DrawImage(bmp, r); } DrawStoneSequence(seq, Brushes.Black, r); 바둑판[x, y] = STONE.white; } CheckOmok(x, y); }
void ResetGame() { bTurn = false; BlackReposit.Clear(); WhiteReposit.Clear(); bReady = true; ResetOMOK_Boad(); System.Array.Clear(buf, 0, BUF_SIZE); buf[0] = (byte)'E'; if (stone == STONE.BLACK) { buf[1] = (byte)'B'; } else if (stone == STONE.WHITE) { buf[1] = (byte)'W'; } stone = 0; hClntSock.Send(buf); }
private void DrawAStone(Revive item) { int x = item.X; int y = item.Y; STONE s = item.Stone; int seq = item.Seq; Rectangle r = new Rectangle(mgn + 눈 * x - 돌 / 2, mgn + 눈 * y - 돌 / 2, 돌, 돌); if (s == STONE.black) { if (imageFlag == false) { g.FillEllipse(bBrush, r); } else { Bitmap bmp = new Bitmap("../../Images/black.png"); g.DrawImage(bmp, r); } DrawStoneSequence(seq, Brushes.White, r); 바둑판[x, y] = STONE.black; } else { if (imageFlag == false) { g.FillEllipse(wBrush, r); } else { Bitmap bmp = new Bitmap("../../Images/white.png"); g.DrawImage(bmp, r); } DrawStoneSequence(seq, Brushes.Black, r); 바둑판[x, y] = STONE.white; } CheckOmok(x, y); }
//오목 전송 void OnSendData2(int x, int y, STONE stone) { Console.WriteLine(myturn); // 서버가 대기중인지 확인한다. if (!mainSock.IsBound) { MsgBoxHelper.Warn("서버가 실행되고 있지 않습니다!"); return; } String STONE = stone.ToString(); Console.WriteLine("x : " + x); Console.WriteLine("Y : " + y); Console.WriteLine("색깔 1-검정, 2-흰돌 : " + stone); string turn = "myturn"; byte[] bDts = Encoding.UTF8.GetBytes("1:" + x + ':' + y + ':' + STONE + ':' + turn + ':'); //서버에 전송한다. mainSock.Send(bDts); }
// 함수중복(복기할 때 사용) : 바둑판[x, y]에 Stone색 돌을 하나 그림 private void DrawAStone(int x, int y, STONE stone) { // 바둑판[x, y]에 돌을 그리기 위한 사각형 Rectangle r = new Rectangle( margin + 눈Size * x - 돌Size / 2, margin + 눈Size * y - 돌Size / 2, 돌Size, 돌Size); // 이미지 또는 FillEllipse() if (stone == STONE.white) { if (imageFlag == false) { g.FillEllipse(wBrush, r); } else { Bitmap bmp = new Bitmap("../../images/white.png"); g.DrawImage(bmp, r); } 바둑판[x, y] = STONE.white; flag = false; } else { if (imageFlag == false) { g.FillEllipse(bBrush, r); } else { Bitmap bmp = new Bitmap("../../images/black.png"); g.DrawImage(bmp, r); } 바둑판[x, y] = STONE.black; flag = true; } }