Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
 public void BroadcastCore()
 {
     Send(player1, core, TOPBYTE.NETVISIONCORE);
     Send(player2, core.ReverseSide(), TOPBYTE.NETVISIONCORE);
 }
Exemplo n.º 3
0
        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);
            }
        }