Esempio n. 1
0
    public static void InsertIntoHand(CardMB cardMb)
    {
        float cardMbX = cardMb.transform.position.x;

        for (int i = 0; i < Hand.Count; i++)
        {
            if (cardMbX < HandMB.CalculatePos(i))
            {
                Hand.Insert(i, cardMb);
                return;
            }
        }

        Hand.Add(cardMb);
    }
Esempio n. 2
0
    public static CardMB Spawn(Card c)
    {
        GameObject cardObject = Instantiate(CardPrefab);
        CardMB     cardMb     = cardObject.GetComponent <CardMB>();

        switch (c.GetCardType())
        {
        case CardType.AttackCard:
            cardMb.CardSprite.sprite = CardBgs[0];
            break;

        case CardType.BuffCard:
            cardMb.CardSprite.sprite = CardBgs[1];
            break;

        case CardType.HealingCard:
            cardMb.CardSprite.sprite = CardBgs[2];
            break;

        case CardType.SummonCard:
            cardMb.CardSprite.sprite = CardBgs[3];
            break;

        default:
            throw new ArgumentException("Invalid card: " + c.GetType().FullName);
        }

        cardMb.CardArt.sprite = c.CardArt;

        TextMeshPro text = cardObject.GetComponentInChildren <TextMeshPro>();

        string[] textLines = c.Description.Split('\n');
        text.text = string.Format("<b>{0}</b>\n<i>{1}</i>\n{2}", textLines);

        cardMb.Init(c, new Vector2(HandMB.CalculatePos(Deck.Hand.Count), 1.5f));

        return(cardMb);
    }