示例#1
0
    public void DrawCard(int amount)
    {
        int cardsToDraw = Mathf.Min(Hand.CardSlotsFree, amount);

        if (cardsToDraw != amount)
        {
            Debug.Log("Adding To many cards to the hand, the maximum is: " + Hand.MaxCardCount);
        }


        Debug.Log("Adding " + cardsToDraw + " cards to the hand of client: " +
                  netIdentity.connectionToClient.connectionId);

        for (int i = 0; i < cardsToDraw; i++)
        {
            CardEntry e = Deck.DrawCard();
            //Hand.AddCard(c);//Add the Card to the server
            GameObject cardInstance = Instantiate(e.Prefab, Deck.DeckPosition, Quaternion.identity);
            NetworkServer.Spawn(cardInstance, GetComponent <NetworkIdentity>().connectionToClient);
            Card c = cardInstance.GetComponent <Card>();
            c.Statistics = e.Statistics;
            Tuple <int[], int[], string[]> networkData = e.StatisticsToNetworkableTypes();
            Debug.Log("Sending Stats");
            c.TargetSendStats(netIdentity.connectionToClient, networkData.Item1, networkData.Item2, networkData.Item3);

            Hand.AddToHand(c.GetComponent <NetworkIdentity>());
            Hand.TargetAddToHand(netIdentity.connectionToClient,
                                 c.GetComponent <NetworkIdentity>()); //Add Card to the client
        }
    }