示例#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);
            }
        }
示例#2
0
        public void setAll(NetvisionCore setCore)
        {
            int i;

            for (i = 0; i < 100; i++)
            {
                cards[i].setAll(setCore.cards[i]);
            }
            home.setAll(setCore.home);
            away.setAll(setCore.away);
        }
示例#3
0
        static public NetvisionCore DeserializeToNetvisionCore(byte[] accptBytes)
        {
            MemoryStream ms = new MemoryStream(accptBytes);

            ms.Position = 0;
            BinaryFormatter bf         = new BinaryFormatter();
            NetvisionCore   resultCore = (NetvisionCore)bf.Deserialize(ms);

            ms.Close();
            return(resultCore);
        }
示例#4
0
文件: Form1.cs 项目: c-p-c/NetVision
 public void setNetvisionCore(NetvisionCore setCore)
 {
     core.setAll(setCore);
     RedrawAll();
 }
示例#5
0
 public void setAll(NetvisionCore setCore)
 {
     int i;
     for (i = 0; i < 100; i++)
     {
         cards[i].setAll(setCore.cards[i]);
     }
     home.setAll(setCore.home);
     away.setAll(setCore.away);
 }
示例#6
0
        public NetvisionCore ReverseSide()
        {
            int i;
            NetvisionCore resultCore = new NetvisionCore();
            resultCore.setAll(this);

            resultCore.home.setAll(this.away);
            resultCore.away.setAll(this.home);

            for (i = 0; i < 100; i++)
            {
                switch (this.cards[i].section)
                {
                    case SECTION.HOMEFIELD:
                        resultCore.cards[i].section = SECTION.AWAYFIELD;
                        break;
                    case SECTION.HOMEHADES:
                        resultCore.cards[i].section = SECTION.AWAYHADES;
                        break;
                    case SECTION.HOMEHAND:
                        resultCore.cards[i].section = SECTION.AWAYHAND;
                        break;
                    case SECTION.HOMELIBRARY:
                        resultCore.cards[i].section = SECTION.AWAYLIBRARY;
                        break;
                    case SECTION.HOMENODEACTIVE:
                        resultCore.cards[i].section = SECTION.AWAYNODEACTIVE;
                        break;
                    case SECTION.HOMENODESLEEP:
                        resultCore.cards[i].section = SECTION.AWAYNODESLEEP;
                        break;

                    case SECTION.AWAYFIELD:
                        resultCore.cards[i].section = SECTION.HOMEFIELD;
                        break;
                    case SECTION.AWAYHADES:
                        resultCore.cards[i].section = SECTION.HOMEHADES;
                        break;
                    case SECTION.AWAYHAND:
                        resultCore.cards[i].section = SECTION.HOMEHAND;
                        break;
                    case SECTION.AWAYLIBRARY:
                        resultCore.cards[i].section = SECTION.HOMELIBRARY;
                        break;
                    case SECTION.AWAYNODEACTIVE:
                        resultCore.cards[i].section = SECTION.HOMENODEACTIVE;
                        break;
                    case SECTION.AWAYNODESLEEP:
                        resultCore.cards[i].section = SECTION.HOMENODESLEEP;
                        break;
                }
                resultCore.cards[i].owner = !this.cards[i].owner;
            }
            return resultCore;
        }
示例#7
0
        public NetvisionCore ReverseSide()
        {
            int           i;
            NetvisionCore resultCore = new NetvisionCore();

            resultCore.setAll(this);

            resultCore.home.setAll(this.away);
            resultCore.away.setAll(this.home);

            for (i = 0; i < 100; i++)
            {
                switch (this.cards[i].section)
                {
                case SECTION.HOMEFIELD:
                    resultCore.cards[i].section = SECTION.AWAYFIELD;
                    break;

                case SECTION.HOMEHADES:
                    resultCore.cards[i].section = SECTION.AWAYHADES;
                    break;

                case SECTION.HOMEHAND:
                    resultCore.cards[i].section = SECTION.AWAYHAND;
                    break;

                case SECTION.HOMELIBRARY:
                    resultCore.cards[i].section = SECTION.AWAYLIBRARY;
                    break;

                case SECTION.HOMENODEACTIVE:
                    resultCore.cards[i].section = SECTION.AWAYNODEACTIVE;
                    break;

                case SECTION.HOMENODESLEEP:
                    resultCore.cards[i].section = SECTION.AWAYNODESLEEP;
                    break;

                case SECTION.AWAYFIELD:
                    resultCore.cards[i].section = SECTION.HOMEFIELD;
                    break;

                case SECTION.AWAYHADES:
                    resultCore.cards[i].section = SECTION.HOMEHADES;
                    break;

                case SECTION.AWAYHAND:
                    resultCore.cards[i].section = SECTION.HOMEHAND;
                    break;

                case SECTION.AWAYLIBRARY:
                    resultCore.cards[i].section = SECTION.HOMELIBRARY;
                    break;

                case SECTION.AWAYNODEACTIVE:
                    resultCore.cards[i].section = SECTION.HOMENODEACTIVE;
                    break;

                case SECTION.AWAYNODESLEEP:
                    resultCore.cards[i].section = SECTION.HOMENODESLEEP;
                    break;
                }
                resultCore.cards[i].owner = !this.cards[i].owner;
            }
            return(resultCore);
        }
示例#8
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);
            }
        }