Exemplo n.º 1
0
    public static BuyStatus BuyCard(BuyableCardEnum cardToBuy)
    {
        //check if card already bought
        if (GetCardAvailability(cardToBuy))
        {
            return(BuyStatus.ALREADY_BOUGHT);
        }

        bool boughtSuccessful = ChangeBananaCountBy(-CARD_COST_MAP[cardToBuy]);

        if (boughtSuccessful)
        {
            HashSet <string> unlockedCards = GetBoughtCards();
            if (!unlockedCards.Contains(cardToBuy.ToString()))
            {
                unlockedCards.Add(cardToBuy.ToString());
                string newCommaSeperatedListOfCards = string.Join(",", unlockedCards.ToArray <string>());
                PlayerPrefs.SetString(CARD_AVAILABILITY_KEY, newCommaSeperatedListOfCards);
                return(BuyStatus.SUCCESSFUL);
            }
            return(BuyStatus.ALREADY_BOUGHT);
        }
        else
        {
            return(BuyStatus.NOT_ENOUGH_BANANAS);
        }
    }
Exemplo n.º 2
0
    public static bool GetCardAvailability(BuyableCardEnum card)
    {
        if (card == BuyableCardEnum.None)
        {
            return(false);
        }
        HashSet <string> unlockedCards = GetBoughtCards();

        return(unlockedCards.Contains(card.ToString()));
    }