Exemplo n.º 1
0
        public Byte[] ToArray()
        {
            SWNetworkMessage message = new SWNetworkMessage();

            message.Push((Byte)poolOfCards.Count);
            message.PushByteArray(poolOfCards.ToArray());

            message.Push((Byte)player1Cards.Count);
            message.PushByteArray(player1Cards.ToArray());

            message.Push((Byte)player2Cards.Count);
            message.PushByteArray(player2Cards.ToArray());

            message.Push(numberOfBooksForPlayer1);
            message.Push(numberOfBooksForPlayer2);

            message.PushUTF8ShortString(player1Id);
            message.PushUTF8ShortString(player2Id);

            message.PushUTF8ShortString(currentTurnPlayerId);
            message.Push(currentGameState);

            message.Push(selectedRank);

            return(message.ToArray());
        }
Exemplo n.º 2
0
        void Encrypt()
        {
            SWNetworkMessage message = new SWNetworkMessage();

            message.Push((Byte)poolOfCards.Count);
            message.PushByteArray(poolOfCards.ToArray());

            message.Push((Byte)player1Cards.Count);
            message.PushByteArray(player1Cards.ToArray());

            message.Push((Byte)player2Cards.Count);
            message.PushByteArray(player2Cards.ToArray());

            message.Push((Byte)booksForPlayer1.Count);
            message.PushByteArray(booksForPlayer1.ToArray());

            message.Push((Byte)booksForPlayer2.Count);
            message.PushByteArray(booksForPlayer2.ToArray());

            message.PushUTF8ShortString(player1Id);
            message.PushUTF8ShortString(player2Id);

            message.PushUTF8ShortString(currentTurnPlayerId);
            message.Push(currentGameState);

            message.Push(selectedRank);

            safeData = AES.EncryptAES128(message.ToArray(), encryptionKey);

            //poolOfCards = new List<byte>();
            //player1Cards = new List<byte>();
            //player2Cards = new List<byte>();

            //booksForPlayer1 = new List<byte>();
            //booksForPlayer2 = new List<byte>();

            //player1Id = null;
            //player2Id = null;

            //currentTurnPlayerId = null;
            //currentGameState = 0;
            //selectedRank = 0;
        }
Exemplo n.º 3
0
        void Encrypt()
        {
            SWNetworkMessage message = new SWNetworkMessage();

            message.Push((Byte)deckOfCards.Count);
            message.PushByteArray(deckOfCards.ToArray());

            message.Push((Byte)player1Hand.Count);
            message.PushByteArray(player1Hand.ToArray());

            message.Push((Byte)player2Hand.Count);
            message.PushByteArray(player2Hand.ToArray());

            message.Push((Byte)player3Hand.Count);
            message.PushByteArray(player3Hand.ToArray());

            message.Push((Byte)player4Hand.Count);
            message.PushByteArray(player4Hand.ToArray());

            message.PushUTF8ShortString(player1Id);
            message.PushUTF8ShortString(player2Id);
            message.PushUTF8ShortString(player3Id);
            message.PushUTF8ShortString(player4Id);

            message.PushUTF8ShortString(player1Name);
            message.PushUTF8ShortString(player2Name);
            message.PushUTF8ShortString(player3Name);
            message.PushUTF8ShortString(player4Name);

            message.Push(player1Team);
            message.Push(player2Team);
            message.Push(player3Team);
            message.Push(player4Team);

            message.PushUTF8ShortString(player1Bid);
            message.PushUTF8ShortString(player2Bid);
            message.PushUTF8ShortString(player3Bid);
            message.PushUTF8ShortString(player4Bid);

            message.PushUTF8ShortString(currentPlayerId);
            message.PushUTF8ShortString(playerToSkipId);
            message.PushUTF8ShortString(highBidPlayerId);
            message.PushUTF8ShortString(highTrickPlayerId);
            message.Push(currentGameState);
            message.PushUTF8ShortString(dealer);
            message.Push(trump);
            message.Push(oppositeTrump);
            message.Push(ledSuit);
            message.Push(highBid);
            message.Push(team1Score);
            message.Push(team2Score);
            message.Push(team1Tricks);
            message.Push(team2Tricks);
            message.Push(winnerTeam);
            message.Push(playedCard);
            message.Push(givenCard1);
            message.Push(givenCard2);
            message.Push(givenCard3);
            message.Push(removedCard1);
            message.Push(removedCard2);
            message.Push(removedCard3);
            message.Push(actionCount);
            message.Push(handCount);

            //safeData = AES.EncryptAES128(message.ToArray(), encryptionKey);
            safeData = message.ToArray();
        }
Exemplo n.º 4
0
        void Encrypt()
        {
            SWNetworkMessage message = new SWNetworkMessage();

            message.Push((Byte)poolOfCards.Count);
            message.PushByteArray(poolOfCards.ToArray());   //nije rekurzija koliko san svatija nego inbuilt funkcija

            message.Push((Byte)player1Cards.Count);
            message.PushByteArray(player1Cards.ToArray());

            message.Push((Byte)player2Cards.Count);
            message.PushByteArray(player2Cards.ToArray());

            message.Push((Byte)player3Cards.Count);
            message.PushByteArray(player3Cards.ToArray());

            message.Push((Byte)player4Cards.Count);
            message.PushByteArray(player4Cards.ToArray());

            message.Push(numberOfBooksForPlayer1);
            message.Push(numberOfBooksForPlayer2);
            message.Push(numberOfBooksForPlayer3);
            message.Push(numberOfBooksForPlayer4);

            message.PushUTF8ShortString(player1Id);
            message.PushUTF8ShortString(player2Id);
            message.PushUTF8ShortString(player3Id);
            message.PushUTF8ShortString(player4Id);

            message.PushUTF8ShortString(currentTurnPlayerId);
            message.Push(currentGameState);

            message.Push(selectedRank);
            message.PushUTF8ShortString(currentTurnTargetPlayerId);

            //Debug.Log(message); //za testiranje


            //
            safeData     = AES.EncryptAES128(message.ToArray(), encryptionKey);
            poolOfCards  = new List <byte>();
            player1Cards = new List <byte>();
            player2Cards = new List <byte>();
            player3Cards = new List <byte>();
            player4Cards = new List <byte>();

            numberOfBooksForPlayer1 = 0;
            numberOfBooksForPlayer2 = 0;
            numberOfBooksForPlayer3 = 0;
            numberOfBooksForPlayer4 = 0;

            player1Id = null;
            player2Id = null;
            player3Id = null;
            player4Id = null;

            currentTurnPlayerId       = null;
            currentGameState          = 0;
            selectedRank              = 0;
            currentTurnTargetPlayerId = null;
        }