Пример #1
0
 private void GameLoopHandler(NetworkCommsDotNet.PacketHeader header, NetworkCommsDotNet.Connections.Connection connection, string message)
 {
     if (message == "null")
     {
         AffHand();
         if (Cards.Count > 0)
         {
             int       x = ReadLine();
             Card.Card a = Cards[x];
             if (SendPacket <string>("Game", JsonConvert.SerializeObject(a)) == 1)
             {
                 System.Environment.Exit(1);
             }
             Cards.RemoveAt(x);
         }
         else
         {
             if (SendPacket <string>("Game", "end") == 1)
             {
                 System.Environment.Exit(1);
             }
         }
     }
     else
     {
         Console.WriteLine(message);
         _End = true;
     }
 }
Пример #2
0
        // TOOLS FUNCTION
        public int                              AddNewUser(string username, NetworkCommsDotNet.Connections.Connection connection)
        {
            User newUser = new User(username, connection);

            _Users.Add(newUser);
            Console.WriteLine("User " + username + " " + "online");
            return(0);
        }
Пример #3
0
 private void CardPacketHandler(NetworkCommsDotNet.PacketHeader header, NetworkCommsDotNet.Connections.Connection connection, string message)
 {
     Cards = JsonConvert.DeserializeObject <List <Card.Card> >(message);
     if (SendPacket <string>("Start", "") == -1)
     {
         System.Environment.Exit(1);
     }
 }
Пример #4
0
 private void ProtoClient_OnHandshakeReceived(PacketHeader packetHeader, NetworkCommsDotNet.Connections.Connection connection, Common.Packets.S2C.S2C_HandshakeResponse incomingObject)
 {
     ProtoClient.OnHandshakeReceived -= ProtoClient_OnHandshakeReceived;
     if (incomingObject.OK)
     {
         //this.Invoke((Action)delegate { MessageBox.Show(this.GetMainWindow(), "OK!!"); });
         this.Invoke((Action) delegate { this.GetMainWindow().TransitionInto(new LobbyView()); });
     }
     else
     {
         this.Invoke((Action) delegate
         {
             connectButton.IsEnabled = true; MessageBox.Show(this.GetMainWindow(), incomingObject.Message);
         });
     }
 }
Пример #5
0
        private void                            LobbyPacketHandler(NetworkCommsDotNet.PacketHeader header, NetworkCommsDotNet.Connections.Connection connection, string message)
        {
            User user;

            if ((user = getUser(connection.ConnectionInfo.RemoteEndPoint.ToString())) == null)
            {
                return;
            }

            if (message == "ready")
            {
                user._ReadyToPlay = true;
            }
            else if (message == "notReady")
            {
                user._ReadyToPlay = false;
            }
        }
Пример #6
0
 // PacketHandler
 private void                            ConnectionPacketHandler(NetworkCommsDotNet.PacketHeader header, NetworkCommsDotNet.Connections.Connection connection, string username)
 {
     if (getUser(connection.ConnectionInfo.RemoteEndPoint.ToString()) != null)
     {
         return;
     }
     AddNewUser(username, connection);
     Console.WriteLine(connection.ConnectionInfo.RemoteEndPoint.ToString());
 }
Пример #7
0
        private void                            StartPacketHandler(NetworkCommsDotNet.PacketHeader header, NetworkCommsDotNet.Connections.Connection connection, string message)
        {
            User user;

            if ((user = getUser(connection.ConnectionInfo.RemoteEndPoint.ToString())) == null)
            {
                return;
            }

            user._receivedCard = true;
        }
Пример #8
0
        private void                            GamePacketHandler(NetworkCommsDotNet.PacketHeader header, NetworkCommsDotNet.Connections.Connection connection, string message)
        {
            User user;

            Console.WriteLine(message);

            if ((user = getUser(connection.ConnectionInfo.RemoteEndPoint.ToString())) == null)
            {
                return;
            }

            if (message.Equals("end"))
            {
                _Game._GameState = GameState.Done;
                return;
            }

            Card.Card newCard = new Card.Card();
            newCard.Color = JsonConvert.DeserializeObject <Card.Card>(message).Color;
            newCard.Val   = JsonConvert.DeserializeObject <Card.Card>(message).Val;
            newCard.Name  = JsonConvert.DeserializeObject <Card.Card>(message).Name;

            user._Card = newCard;
        }
Пример #9
0
 private static void GameStatePacketHandler(NetworkCommsDotNet.PacketHeader header, NetworkCommsDotNet.Connections.Connection connection, string message)
 {
     Console.WriteLine(message + " WON the round");
 }