Example #1
0
        public bool buyItem(ShopItem item, ShopTouchButton caller)
        {
            int  itemCost  = PlayerPrefs.GetInt(COST_PREFIX + item.ToString(), -1);
            bool returnVal = true;

            if (getItemCount(item) >= caller.shopItemVals.itemCost.Length)
            {
                return(false);
            }
            if (currency >= itemCost)
            {
                setItemBought(item);
                setItemValue(item, caller.shopItemVals.itemValue[getItemCount(item)]);
                setItemCount(item, getItemCount(item) + 1);
                updateCurrency(currency - itemCost);
                alertText.text = "Upgrade bought";
                itemCost       = caller.nextCost(itemCost);
                setItemCost(item, itemCost);
                Debug.Log(getItemCount(item));

                if (getItemCount(item) >= caller.shopItemVals.itemCost.Length || currency < itemCost)
                {
                    returnVal = false;
                }
            }
            else
            {
                alertText.text = "Insufficient Funds";
            }
            //Debug.Log(this);
            return(returnVal);
        }
Example #2
0
        public bool isItemBought(ShopItem item)
        {
            int itemBuyStatus = PlayerPrefs.GetInt(BOUGHT_PREFIX + item.ToString(), 0);

            return((itemBuyStatus == 1) ? true : false);
        }
Example #3
0
 public int getItemValue(ShopItem item)
 {
     return(PlayerPrefs.GetInt(VALUE_PREFIX + item.ToString(), 0));
 }
Example #4
0
 public bool hasKey(ShopItem item)
 {
     return(PlayerPrefs.HasKey(COST_PREFIX + item.ToString()) && PlayerPrefs.HasKey(COUNT_PREFIX + item.ToString()));
 }
Example #5
0
 public void setItemValue(ShopItem item, int value)
 {
     PlayerPrefs.SetInt(VALUE_PREFIX + item.ToString(), value);
     PlayerPrefs.Save();
 }
Example #6
0
 public int getItemCount(ShopItem item)
 {
     return(PlayerPrefs.GetInt(COUNT_PREFIX + item.ToString(), 0));
 }
Example #7
0
 public void setItemCount(ShopItem item, int count)
 {
     PlayerPrefs.SetInt(COUNT_PREFIX + item.ToString(), count);
     PlayerPrefs.Save();
 }
Example #8
0
 public int getItemCost(ShopItem item)
 {
     return(PlayerPrefs.GetInt(COST_PREFIX + item.ToString(), -1));
 }
Example #9
0
 public void setItemBought(ShopItem item)
 {
     PlayerPrefs.SetInt(BOUGHT_PREFIX + item.ToString(), 1);
     PlayerPrefs.Save();
 }