Exemplo n.º 1
0
    public Sprite GetCardSpriteByInt(int _cardType)
    {
        Sprite[]     collections = null;
        int          cardPoint   = 1;
        CardInfoType cardType    = (CardInfoType)_cardType;
        CardType     type        = GetCardTypeAndPoints(cardType.ToString(), out cardPoint);

        switch (type)
        {
        case CardType.Club: collections = cardsClub; break;

        case CardType.Diamond: collections = cardsDiamond; break;

        case CardType.Heart: collections = cardsHeart; break;

        case CardType.Spade: collections = cardsSpade; break;
        }

        //One or Ace has a index of one
        if (cardPoint >= 14)
        {
            cardPoint = 1;
        }

        int cardIndex = cardPoint - 1;

        return(collections[cardIndex]);
    }
Exemplo n.º 2
0
    // Use this for initialization
    public void AssignCard(CardInfoType cardInfoType, CardPoints cardPoints)
    {
        this.cardInfoType = cardInfoType;
        this.cardPoints   = cardPoints;

        string[] cardInfo = cardInfoType.ToString().Split('_');
        cardType = (CardType)System.Enum.Parse(typeof(CardType), cardInfo[0], true);


        switch (cardPoints)
        {
        case CardPoints.One: points = 1; break;

        case CardPoints.Two: points = 2; break;

        case CardPoints.Three: points = 3; break;

        case CardPoints.Four: points = 4; break;

        case CardPoints.Five: points = 5; break;

        case CardPoints.Six: points = 6; break;

        case CardPoints.Seven: points = 7; break;

        case CardPoints.Eight: points = 8; break;

        case CardPoints.Nine: points = 9; break;

        default: points = 10; break;
        }

        Sprite sprite = null;

        switch (cardType)
        {
        case CardType.Club: sprite = CardsManager.instance.cardsClub[(int)cardPoints]; break;

        case CardType.Diamond: sprite = CardsManager.instance.cardsDiamond[(int)cardPoints]; break;

        case CardType.Heart: sprite = CardsManager.instance.cardsHeart[(int)cardPoints]; break;

        case CardType.Spade: sprite = CardsManager.instance.cardsSpade[(int)cardPoints]; break;
        }

        if (imgIcon != null)
        {
            imgIcon.sprite = sprite;
        }
    }