Esempio n. 1
0
 void Update()
 {
     if (collidedCard.isPlayable() && collidedCard.isDropped() && collidedCard.isInRange())                             //if a card is playable and in the rage of collision
     {
         collidedObject.transform.parent.gameObject.GetComponent <HandController>().RemoveCard(collidedCard.getCard()); //remove the card from user hand
         Neutral.cardDropped(collidedCard);                                                                             //drop the card on table
         if (Neutral.getHand()[0].gameObject.activeSelf)                                                                //if there is an active card on table
         {
             if (collidedCard.getCard().getValue() == Neutral.getHand()[0].getCard().getValue() || collidedCard.getCard().getValue() == 10)
             {
                 Player.AddAwardedCards(Neutral.getCardList());
                 Neutral.ClearCardsAtHand();
                 Neutral.getHand()[0].gameObject.SetActive(false);
             }
             else
             {
                 //Neutral.cardDropped(collidedCard);
             }
         }
         else //if the drop zone empty
              //Neutral.cardDropped(collidedCard);
         {
             Neutral.getHand()[0].gameObject.SetActive(true);
         }
         collidedCard.setInRange(false);
         collidedObject.SetActive(false);
         turn++;
     }
 }
Esempio n. 2
0
    private void ComputerMove()
    {
        List <CardController> computerCards = opponentHand.getHand();
        List <CardController> cardOnTable   = neutral.getHand();
        bool found  = false;
        int  random = 0;

        if (neutral.getHand()[0].gameObject.activeSelf)//if there is a card in mid table
        {
            for (int i = 0; i < computerCards.Count; i++)
            {
                if ((computerCards[i].gameObject.activeSelf) && (computerCards[i].getCard().getValue() == cardOnTable[0].getCard().getValue() || computerCards[i].getCard().getValue() == 10))
                {
                    drop.ComputerDrop(opponentHand, computerCards[i]);
                    opponentHand.AddAwardedCards(neutral.getCardList());
                    neutral.ClearCardsAtHand();
                    cardOnTable[0].gameObject.SetActive(false);
                    found = true;
                    break;
                }
            }
            if (!found)//if there is not an identical card on table, put a card down randomly
            {
                random = Random.Range(0, 4);
                if (computerCards[random].gameObject.activeSelf)
                {
                    drop.ComputerDrop(opponentHand, computerCards[random]);
                    //found = true;
                }
            }
        }
        else //if there isnt a card on table
        {
            for (int i = 0; i < computerCards.Count; i++)
            {
                if (computerCards[i].gameObject.activeSelf)
                {
                    drop.ComputerDrop(opponentHand, computerCards[i]);
                    neutral.getHand()[0].gameObject.SetActive(true);
                    break;
                }
            }
        }
    }