void Decrypt() { byte[] byteArray = AES.DecryptAES128(safeData, encryptionKey); SWNetworkMessage message = new SWNetworkMessage(byteArray); byte poolOfCardsCount = message.PopByte(); poolOfCards = message.PopByteArray(poolOfCardsCount).ToList(); byte player1CardsCount = message.PopByte(); player1Cards = message.PopByteArray(player1CardsCount).ToList(); byte player2CardsCount = message.PopByte(); player2Cards = message.PopByteArray(player2CardsCount).ToList(); byte booksForPlayer1Count = message.PopByte(); booksForPlayer1 = message.PopByteArray(booksForPlayer1Count).ToList(); byte booksForPlayer2Count = message.PopByte(); booksForPlayer2 = message.PopByteArray(booksForPlayer2Count).ToList(); player1Id = message.PopUTF8ShortString(); player2Id = message.PopUTF8ShortString(); currentTurnPlayerId = message.PopUTF8ShortString(); currentGameState = message.PopInt32(); selectedRank = message.PopInt32(); }
public void ApplyByteArray(Byte[] byteArray) { SWNetworkMessage message = new SWNetworkMessage(byteArray); byte poolOfCardsCount = message.PopByte(); poolOfCards = message.PopByteArray(poolOfCardsCount).ToList(); byte player1CardsCount = message.PopByte(); player1Cards = message.PopByteArray(player1CardsCount).ToList(); byte player2CardsCount = message.PopByte(); player2Cards = message.PopByteArray(player2CardsCount).ToList(); numberOfBooksForPlayer1 = message.PopInt32(); numberOfBooksForPlayer2 = message.PopInt32(); player1Id = message.PopUTF8ShortString(); player2Id = message.PopUTF8ShortString(); currentTurnPlayerId = message.PopUTF8ShortString(); currentGameState = message.PopInt32(); selectedRank = message.PopInt32(); }
public void OnRankSelectedRemoteEvent(SWNetworkMessage message) { Debug.Log("OnRankSelectedRemoteEvent:: Message is " + message); int intRank = message.PopInt32(); OnRankSelectedEvent.Invoke((Ranks)intRank); }
public void OnAttack(SWNetworkMessage msg) { int damage = msg.PopInt32(); int health = msg.PopInt32(); string hasMon = msg.PopUTF8ShortString(); Debug.Log("recieved damage " + damage + " units"); if (hasMon.Equals("DoesntHasMon")) { Debug.Log(hasMon); //checkText.text = hasMon; if (gm.currentTurn.Equals(gm.hostPlayer.getId())) { gm.remotePlayer.setHp(gm.remotePlayer.getHp() - damage); remoteHealthbar.hp_decrease(damage); } else if (gm.currentTurn.Equals(gm.remotePlayer.getId())) { gm.hostPlayer.setHp(gm.hostPlayer.getHp() - damage); localHealthbar.hp_decrease(damage); } } else if (hasMon.Equals("HasMon")) { //TODO ให้มอนต่อสู้กัน } if (!gm.checkWinner().Equals("")) { if (gm.checkWinner().Equals(gm.hostPlayer.getId())) { Debug.Log(gm.hostPlayer.getName() + " wins.."); win.SetActive(true); } else if (gm.checkWinner().Equals(gm.remotePlayer.getId())) { Debug.Log(gm.remotePlayer.getName() + " wins.."); lose.SetActive(true); } } }
public void OnRankSelectedRemoteEvent(SWNetworkMessage message) { int intRank = message.PopInt32(); OnRankSelectedEvent.Invoke((Ranks)intRank); }
public void OnTrumpSelectedRemoteEvent(SWNetworkMessage message) { int intTrump = message.PopInt32(); OnTrumpSelected.Invoke(intTrump); }
public void OnBidSelectedRemoteEvent(SWNetworkMessage message) { int intBid = message.PopInt32(); OnBidSelected.Invoke(intBid); }
void Decrypt() { //int retries = 0; byte[] byteArray; /*while (true) * { * try * { * byteArray = AES.DecryptAES128(safeData, encryptionKey); * break; * } * catch (ArgumentNullException e) * { * if (retries < 2) * { * retries++; * SetupVariables(); * byteArray = AES.DecryptAES128(safeData, encryptionKey); * } * else * throw; * } * }*/ byteArray = safeData; SWNetworkMessage message = new SWNetworkMessage(byteArray); byte deckOfCardsCount = message.PopByte(); deckOfCards = message.PopByteArray(deckOfCardsCount).ToList(); byte player1HandCount = message.PopByte(); player1Hand = message.PopByteArray(player1HandCount).ToList(); byte player2HandCount = message.PopByte(); player2Hand = message.PopByteArray(player2HandCount).ToList(); byte player3HandCount = message.PopByte(); player3Hand = message.PopByteArray(player3HandCount).ToList(); byte player4HandCount = message.PopByte(); player4Hand = message.PopByteArray(player4HandCount).ToList(); player1Id = message.PopUTF8ShortString(); player2Id = message.PopUTF8ShortString(); player3Id = message.PopUTF8ShortString(); player4Id = message.PopUTF8ShortString(); player1Name = message.PopUTF8ShortString(); player2Name = message.PopUTF8ShortString(); player3Name = message.PopUTF8ShortString(); player4Name = message.PopUTF8ShortString(); player1Team = message.PopInt32(); player2Team = message.PopInt32(); player3Team = message.PopInt32(); player4Team = message.PopInt32(); player1Bid = message.PopUTF8ShortString(); player2Bid = message.PopUTF8ShortString(); player3Bid = message.PopUTF8ShortString(); player4Bid = message.PopUTF8ShortString(); currentPlayerId = message.PopUTF8ShortString(); playerToSkipId = message.PopUTF8ShortString(); highBidPlayerId = message.PopUTF8ShortString(); highTrickPlayerId = message.PopUTF8ShortString(); currentGameState = message.PopInt32(); dealer = message.PopUTF8ShortString(); trump = message.PopInt32(); oppositeTrump = message.PopInt32(); ledSuit = message.PopInt32(); highBid = message.PopInt32(); team1Score = message.PopInt32(); team2Score = message.PopInt32(); team1Tricks = message.PopInt32(); team2Tricks = message.PopInt32(); winnerTeam = message.PopInt32(); playedCard = message.PopByte(); givenCard1 = message.PopByte(); givenCard2 = message.PopByte(); givenCard3 = message.PopByte(); removedCard1 = message.PopByte(); removedCard2 = message.PopByte(); removedCard3 = message.PopByte(); actionCount = message.PopInt32(); handCount = message.PopInt32(); }