Example #1
0
    public void ReplaceBlankCard()
    {
        for (int i = 0; i < slots.Length; i++)
        {
            Card card = slots [i].GetComponentInChildren <Card> ();
            if (card != null)
            {
                if (card.myCardType == Card.CardType.BLANK_CARD)
                {
                    int rnd = Random.Range(0, searchables.Count);

                    GameObject newCard = searchables [rnd];


                    RectTransform rectTransform = newCard.GetComponent <RectTransform> ();
                    UtilScript.AlignRectTransformToParent(rectTransform);

                    newCard.transform.SetParent(slots [i].transform, false);
                    newCard.SetActive(true);
                    hand.Add(newCard);

                    searchables.Remove(searchables[rnd]);


                    DeactivateCard(card.gameObject, false);
                    break;
                }
                else
                {
                }
            }
        }
    }
Example #2
0
    IEnumerator LoadCards()
    {
        for (int i = 0; i < slots.Length; i++)
        {
            Card card = slots [i].GetComponentInChildren <Card> ();
            if (card != null)
            {
                if (card.mySlotState == Card.SlotState.CARD_SLOT)
                {
                    DeactivateCard(card.gameObject, true);
                }
            }
        }

        Debug.Log("Loading");
        isLoading = true;

        //Insert Loading code

        yield return(new WaitForSeconds(loadTime));

        isLoading = false;

        if (tempDeck.Count >= slots.Length)
        {
            for (int i = 0; i < slots.Length; i++)
            {
                int num = Random.Range(0, tempDeck.Count - 1);

                drawnCard = tempDeck [num];
                hand.Add(drawnCard);
                tempDeck.Remove(drawnCard);

//			cards [i] = Instantiate(drawnCard,slots [i].transform.position,Quaternion.identity)  as GameObject;
                cards [i] = drawnCard;

                rectTransform = cards [i].GetComponent <RectTransform> ();
                UtilScript.AlignRectTransformToParent(rectTransform);

                cards [i].transform.SetParent(slots [i].transform, false);
                cards [i].SetActive(true);
            }
        }
        else
        {
//			print ("Not enough cards in Deck");

            for (int i = 0; i < tempDeck.Count + 1; i++)
            {
                int num = Random.Range(0, tempDeck.Count - 1);

                drawnCard = tempDeck [num];
                hand.Add(drawnCard);
                tempDeck.Remove(drawnCard);

                cards [i] = drawnCard;

                RectTransform rectTransform = cards [i].GetComponent <RectTransform> ();
                UtilScript.AlignRectTransformToParent(rectTransform);

                cards [i].transform.SetParent(slots [i].transform, false);
                cards [i].SetActive(true);
            }

            ReloadDeck();
        }


        Debug.Log("Loaded");

        //Insert New cards code
    }