Пример #1
0
 public GameState()
 {
     players     = new List <PlayerState>();
     deck        = UNOCard.Shuffle(UNOCard.GetDeck());
     currentCard = deck[0];
     deck        = UNOCard.RemoveCard(deck, currentCard);
 }
Пример #2
0
        public void Initialize()
        {
            deck        = UNOCard.Shuffle(UNOCard.GetDeck());
            currentCard = deck[0];
            int count = 1;

            foreach (PlayerState player in players)
            {
                player.currentCard = currentCard;
                player.playerCards = SubArray(deck, count, Constants.START_CARDS);
                player.noOfCards   = Constants.START_CARDS;
                player.validCards  = UNOCard.GetValidCards(currentCard, player.playerCards);
                count += Constants.START_CARDS;
            }
        }
Пример #3
0
 public void StartServer(string username)
 {
     try
     {
         deck          = UNOCard.Shuffle(UNOCard.GetDeck());
         _serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
         _serverSocket.Bind(new IPEndPoint(GetIPAddress(), port));
         players[count++] = new PlayerState(_serverSocket, username, true);
         Debug.WriteLine("Count incresed to: " + count);
         _serverSocket.Listen(Constants.MAX_PLAYERS);
         Debug.WriteLine("Server started at: " + GetIPAddress().ToString());
         _serverSocket.BeginAccept(_serverSocket.ReceiveBufferSize, new AsyncCallback(AcceptCallback), null);
     }
     catch (Exception e)
     {
         Debug.WriteLine(e.ToString());
     }
 }