// We don't have to fiddle with a 'Hand' instance in this case since this is the enemy.
    // We just trust and render whatever the master client sends us.
    void UpdateEnemyCards(int ammount)
    {
        // Only makes sense if this is the enemy's hand
        Assert.IsTrue(side.owner == Owner.ENEMY);

        int numberOfCardsInEnemyHand = transform.childCount;

        // No work needed if the total cards remain the same.
        if (numberOfCardsInEnemyHand == ammount)
        {
            return;
        }

        // We have to remove cards
        if (numberOfCardsInEnemyHand > ammount)
        {
            for (int i = numberOfCardsInEnemyHand - 1; i >= ammount; i--)
            {
                Destroy(myTransform.GetChild(i).gameObject);
            }
        }
        else
        {
            // We have to add cards
            int            add           = ammount - numberOfCardsInEnemyHand;
            CardGUI_canvas cardGUIPrefab = Prefabs.Get("cardGUI_canvas").GetComponent <CardGUI_canvas>();

            for (int i = 0; i < add; i++)
            {
                CardGUI_canvas cardCpy = Instantiate(cardGUIPrefab, myTransform);
                cardCpy.Location = CardLocation.ENEMY_HAND;
            }
        }
    }
Beispiel #2
0
    public void TakeUp(string cardId)
    {
        CardGUI_canvas cardGUIPrefab = Prefabs.Get("cardGUI_canvas").GetComponent <CardGUI_canvas>();

        CardGUI_canvas cardCpy = Instantiate(cardGUIPrefab, myTransform);

        cardCpy.CardId   = cardId;
        cardCpy.Location = CardLocation.GAME;
    }
    public void Open(Card[] cards)
    {
        for (int i = 0; i < cards.Length; i++)
        {
            Transform      cardGUITransf = chooseCardTransform.GetChild(i);
            CardGUI_canvas cardGUI       = cardGUITransf.GetComponent <CardGUI_canvas>();
            cardGUI.CardId = cards[i].Id;
        }

        chooseCardPanel.SetActive(true);
    }
    // In this case we have to add the cards to the hand instance since this is our hand.
    void UpdatePlayerCards(Card[] cardsToAdd)
    {
        Assert.IsTrue(side.owner == Owner.PLAYER);
        CardGUI_canvas cardGUIPrefab = Prefabs.Get("cardGUI_canvas").GetComponent <CardGUI_canvas>();

        for (int i = 0; i < cardsToAdd.Length; i++)
        {
            CardGUI_canvas cardGUI = Instantiate(cardGUIPrefab, myTransform);
            cardGUI.Location = CardLocation.PLAYER_HAND;
            cardGUI.CardId   = cardsToAdd[i].Id;
        }
    }
Beispiel #5
0
    private void Start()
    {
        rectTransform = GetComponent <RectTransform>();

        // Weird hack to get the disabled object at runtime
        GameObject detail = GameObject.FindGameObjectWithTag("DetailCardWrapper");

        detailCard = detail.transform.GetChild(0).GetComponent <CardGUI_canvas>();

        hand = transform.GetComponentInParent <HandGUI_canvas>();

        canvas   = GetComponentInParent <Canvas>();
        rtCanvas = canvas.GetComponent <RectTransform>();

        raycaster = canvas.GetComponent <GraphicRaycaster>();
    }
    void PlayerPlayedCard(int response, string cardId, int cardPositionInHand, int squarePosition)
    {
        CardGUI_canvas cardGUI = GetCardGUIAtPosition(cardPositionInHand);

        if (response == Responses.CARD_PLAYED_FAILED)
        {
            RebuildLayout();
            return;
        }

        string cardInHandId = cardGUI.CardId;

        if (cardInHandId != cardId)
        {
            Debug.LogWarning(string.Format("Played card (%s) doesn't match the card at that position (%s, %d)",
                                           cardId, cardInHandId, cardPositionInHand));
            return;
        }

        RemoveCardAtPosition(cardPositionInHand);
        RebuildLayout();
    }