Ejemplo n.º 1
0
    public void AddCard(Card card, float delay = 0)
    {
        RectTransform tome = (tomes[currentTomeIndex].transform as RectTransform);

        CardGUI newCard = Instantiate(cardGUIPrefab, transform);

        newCard.Init(card, tome); // give the gui a reference to the card data
        cards.Insert(0, newCard);

        if (state == State.Mini)
        {
            // size / position of new card if added while in mini mode:
            RectTransform rt = (newCard.transform as RectTransform);
            rt.SetParent(newCard.tomeGUI);
            rt.anchoredPosition = new Vector2(0, 0);
            rt.localScale       = Vector3.zero;
        }

        PositionCards();
    }
Ejemplo n.º 2
0
    /*
     * public void PopCard() {
     *  LoseCardAt(cards.Count - 1);
     * }
     * public void DestroyCard() {
     *  LoseCardAt(0);
     * }*/
    void LoseCard(CardGUI card)
    {
        int index = cards.IndexOf(card);

        if (cards.Count == 0)
        {
            return;
        }
        if (index < 0)
        {
            return;
        }
        if (index >= cards.Count)
        {
            return;
        }


        cards[index].AnimateTo(new Vector3(100, 0, 0), Quaternion.Euler(0, 0, 1000), transform.localScale.x, 0);
        Destroy(cards[index].gameObject, .2f);

        cards.RemoveAt(index);
        PositionCards();
    }