static void ServerOnRecv(int remoteID, byte[] accptBytes) { TOPBYTE topbyte = (TOPBYTE)accptBytes[0]; accptBytes = VisionFunctions.DeleteTopByte(accptBytes); if (topbyte == TOPBYTE.STRING) { string sendStr; sendStr = VisionFunctions.DeserializeToString(accptBytes); //fm1.Chat_Add(string.Format("server:client{0}からの通信>{1}", remoteID, accptStr)); sv.Broadcast(sendStr, TOPBYTE.STRING); } else if (topbyte == TOPBYTE.NETVISIONCORE) { NetvisionCore accptCore = new NetvisionCore(); accptCore.setAll(VisionFunctions.DeserializeToNetvisionCore(accptBytes)); if (remoteID == sv.player1) { sv.core.setAll(accptCore); } else if (remoteID == sv.player2) { sv.core.setAll(accptCore.ReverseSide()); } // 返信 sv.BroadcastCore(); } else if (topbyte == TOPBYTE.DECK) { Card[] accptDeck = new Card[50]; accptDeck = VisionFunctions.DeserializeToDeck(accptBytes); if (remoteID == sv.player1) { for (int i = 0; i < 50; i++) { sv.core.cards[i].setAll(accptDeck[i]); } } else if (remoteID == sv.player2) { for (int i = 0; i < 50; i++) { sv.core.cards[50 + i].setAll(accptDeck[i]); } } if (svStat == SERVERSTAT.PLAYING) { sv.StartGame(); sv.BroadcastCore(); } } else { string sendStr; sendStr = accptBytes.Length.ToString(); sv.Broadcast(sendStr, TOPBYTE.STRING); } }
public void Send(int remoteID, object sendObj, TOPBYTE topbyte) { byte[] sendBytes = VisionFunctions.Serialize(sendObj); sendBytes = VisionFunctions.SetTopByte(sendBytes, (byte)topbyte); try { Send(remoteID, sendBytes); } catch (Exception ex) { Program.fm1.Chat_Add(ex.Message); } }
static void ClientOnRecv(int remoteID, byte[] accptBytes) { byte[] accptBytes2 = VisionFunctions.DeleteTopByte(accptBytes); string accptStr; NetvisionCore accptCore; switch ((TOPBYTE)accptBytes[0]) { case TOPBYTE.STRING: accptStr = VisionFunctions.DeserializeToString(accptBytes2); fm1.Chat_Add(string.Format("client:server{0}からの通信>{1}", remoteID, accptStr)); break; case TOPBYTE.NETVISIONCORE: accptCore = VisionFunctions.DeserializeToNetvisionCore(accptBytes2); fm1.setNetvisionCore(accptCore); break; } }
private void pictureBox1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; g.Clear(pictureBox1.BackColor); if (listBox1.SelectedIndex != -1) { int id = cardOrder[cardNum - listBox1.SelectedIndex - 1]; if (cardDB[card[id].no].bmp != null) { VisionFunctions.DrawImage_CenterBottom(g, cardDB[card[id].no].bmp, pictureBox1); } else { VisionFunctions.DrawImage_Noimage(g, cardDB[card[id].no], pictureBox1); } } }
//============================== ゲーム進行 ============================== public void StartGame() { // カード・コアを初期化 core.Initialize(); // coreにデッキの情報を書き込み for (int i = 0; i < 50; i++) { core.home.libraryOrder[i] = i; core.cards[i].section = SECTION.HOMELIBRARY; core.cards[i].owner = true; core.away.libraryOrder[i] = 50 + i; core.cards[50 + i].section = SECTION.AWAYLIBRARY; core.cards[50 + i].owner = false; } core.home.libraryNum = 50; core.away.libraryNum = 50; VisionFunctions.Shuffle(core.home.libraryOrder, core.home.libraryNum); VisionFunctions.Shuffle(core.away.libraryOrder, core.away.libraryNum); }