示例#1
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;
        }