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
    public void AddCardToPlayer(string owner, string cardName)
    {
        SWNetworkMessage msg = new SWNetworkMessage();

        msg.PushUTF8ShortString(owner);
        msg.PushUTF8ShortString(cardName);
        roomRemoteEventAgent.Invoke(CARD_HAS_OWNER, msg);
    }
Exemplo n.º 3
0
    public void UpdatePlayerMana(string player, int manaRemain, string solution)
    {
        SWNetworkMessage msg = new SWNetworkMessage();

        msg.PushUTF8ShortString(player);
        msg.PushUTF8ShortString(manaRemain.ToString());
        msg.PushUTF8ShortString(solution);
        roomRemoteEventAgent.Invoke(UPDATE_MANA, msg);
    }
Exemplo n.º 4
0
        public void NotifyHostPlayerTargetPlayerSelected(string targetPlayer)   //testing
        {
            SWNetworkMessage message = new SWNetworkMessage();

            message.PushUTF8ShortString(targetPlayer);
            roomRemoteEventAgent.Invoke(TARGET_PLAYER_SELECTED, message);;
        }
Exemplo n.º 5
0
 public void OnButtonPressed(VirtualButtonBehaviour vb)
 {
     buttonEvent = vb.VirtualButtonName;
     if (gm.currentTurn.Equals(gm.hostPlayer.getId()))
     {
         if (buttonEvent.Equals("attackBtn") && gm.canAttack)
         {
             if (gm.canAttack)
             {
                 showAnimation("attack");
                 SWNetworkMessage msg = new SWNetworkMessage();
                 msg.Push(attack);
                 msg.Push(health);
                 msg.PushUTF8ShortString("DoesntHasMon");
                 netcode.NotifyOpponentAttack(msg);
                 gm.canAttack = false;
             }
         }
         else if (buttonEvent.Equals("targetBtn") && !gm.onWaitingTarget)
         {
             Debug.Log("target selected!!!!");
             SWNetworkMessage msg = new SWNetworkMessage();
             msg.Push(attack);
             msg.Push(health);
             netcode.AddTargetCard(msg);
             showAnimation("hit");
         }
     }
 }
Exemplo n.º 6
0
    void FireBullet()
    {
        SWNetworkMessage msg = new SWNetworkMessage();

        msg.Push(launchPosition.position);
        msg.Push(transform.forward);
        msg.PushUTF8ShortString(NetworkClient.Instance.PlayerId);
        remoteEventAgent.Invoke("fire", msg);
    }
Exemplo n.º 7
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.º 8
0
    public void makeFight()
    {
        SWNetworkMessage msg = new SWNetworkMessage();

        //TODO quick attack ใน runeterra?
        //TODO ประกาศว่าใครตายหลังจบการต่อสู้
        Debug.Log("make fight");
        if (attackCard_attack >= targetCard_health)
        {
            //การ์ดที่โจมตีชนะ
            msg.PushUTF8ShortString("win fight");
            if (currentTurn.Equals(hostPlayer.getId()))
            {
                damageToOpponent(attackCard_attack - targetCard_health);
            }
            else
            {
                damageToHost(attackCard_attack - targetCard_health);
            }
            Debug.Log("win fight");
        }
        else if (attackCard_attack < targetCard_health && targetCard_attack >= attackCard_health)
        {
            msg.PushUTF8ShortString("lose fight");
            if (currentTurn.Equals(hostPlayer.getId()))
            {
                damageToHost(attackCard_attack - targetCard_health);
            }
            else
            {
                damageToOpponent(attackCard_attack - targetCard_health);
            }
            Debug.Log("lose fight");
        }
        else if (attackCard_attack < targetCard_health && targetCard_attack < attackCard_health)
        {
            msg.PushUTF8ShortString("draw");
            Debug.Log("draw");
        }
    }
Exemplo n.º 9
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.º 10
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;
        }