Пример #1
0
    void UpdateCurrentPrice()
    {
        // Set the price if it has multiple price count
        if (ShopItem.Prices.Count > 1)
        {
            int currentItemLevel = GameSaveManager.Instance.GetPurchaseLevel(ShopItem.ID);
            _CurrentPriceModel = ShopItem.GetPurchasedLevel(currentItemLevel + 1);

            // reached highest level
            if (_CurrentPriceModel.Level == -1)
            {
//				_MaxedOut = false;
            }

            // set price
            ItemPrice.text = _CurrentPriceModel.Price.ToString();
        }
        else
        {
            // cek udah beli aja karena cuma ada 1 level

            _CurrentPriceModel = ShopItem.GetPurchasedLevel(0);

            bool purchased = GameSaveManager.Instance.CheckPurchase(ShopItem.ID);
            if (purchased)
            {
                ItemPrice.text = "";
            }
            else
            {
                ItemPrice.text = _CurrentPriceModel.Price.ToString();
            }
        }
    }
Пример #2
0
    void UpdateCurrentPrice()
    {
        bool eligibleToBuy = false;

        // Set the price if it has multiple price count
        if (ShopItem.Prices.Count > 1)
        {
            int currentItemLevel = GameSaveManager.Instance.GetPurchaseLevel(ShopItem.ID);
            _CurrentPriceModel = ShopItem.GetPurchasedLevel(currentItemLevel + 1);

            // reached highest level
            if (_CurrentPriceModel.Level <= -1)
            {
                eligibleToBuy  = false;
                PriceText.text = "";
            }
            else
            {
                eligibleToBuy = true;
                // set price
                PriceText.text = _CurrentPriceModel.Price.ToString();
            }
        }
        else
        {
            // cek already purchased single priced (not upgrade-able item)

            _CurrentPriceModel = ShopItem.GetPurchasedLevel(0);

            bool purchased = GameSaveManager.Instance.CheckPurchase(ShopItem.ID);
            if (purchased)
            {
                eligibleToBuy  = false;
                PriceText.text = "";
            }
            else
            {
                eligibleToBuy  = true;
                PriceText.text = _CurrentPriceModel.Price.ToString();
            }
        }

        // check price
        if (eligibleToBuy)
        {
            int currentCoin = GameSaveManager.Instance.GetCoins();
            if (currentCoin >= _CurrentPriceModel.Price)
            {
                eligibleToBuy = true;
            }
            else
            {
                eligibleToBuy = false;
            }
        }

        BuyButton.gameObject.SetActive(eligibleToBuy);
    }