Example #1
0
    public void PlayCard()
    {
        if (userCardHand.GetUserTag() != "AI")
        {
            //Debug.Log("___________________________________________________________________");
        }
        else
        {
            switch (this.uniqueCardIDColor)
            {
            case 0:
                this.GetComponent <Renderer>().material.color = Color.yellow;
                break;

            case 1:
                this.GetComponent <Renderer>().material.color = Color.green;
                break;

            case 2:
                this.GetComponent <Renderer>().material.color = Color.blue;
                break;

            case 3:
                this.GetComponent <Renderer>().material.color = Color.red;
                break;
            }
        }

        SetCardCheck(true);

        SetCardState(CardState.CardInPile);

        GameObject clonePlayedCard = Instantiate(this.gameObject);

        clonePlayedCard.transform.position = this.transform.position;
        clonePlayedCard.GetComponent <PlayingBehaviour>().enabled = true;

        List <GameObject> userCardHandList = userCardHand.GetCardHand();

        int cardRemovedId = userCardHandList.Count;

        for (int i = 0; i < userCardHandList.Count; i++)
        {
            if (userCardHandList[i].GetComponent <CardBehaviour>().GetCardCheck() == true)
            {
                userCardHand.GetDeck().GetComponent <DeckBehaviour>().GetPileOfCards().AddCardToPile(userCardHandList[i]);
                cardRemovedId = i;
            }
            else if (i > cardRemovedId)
            {
                userCardHandList[i].transform.position -= userCardHand.GetHandOffSet();
                userCardHandList[i].GetComponent <CardBehaviour>().SetOriginalCardPos(userCardHandList[i].transform.position);
            }
        }

        userCardHandList.RemoveAt(cardRemovedId);

        for (int i = 0; i < userCardHandList.Count; i++)
        {
            if (userCardHand.GetUserTag() != "AI")
            {
                //Debug.Log("CardInHANDNumber --> " + userCardHandList[i].GetComponent<CardBehaviour>().GetUniqueCardIDNumber() + " CardInHANDColor --> " + userCardHandList[i].GetComponent<CardBehaviour>().GetUniqueCardIDColor());
            }
        }

        userCardHand.UpdateCardHand(userCardHandList);

        if (userCardHand.GetUserTag() != "AI")
        {
            StartCoroutine(userCardHand.GetDeck().GetComponent <DeckBehaviour>().GetGMRef().AITurn());
        }
    }