Beispiel #1
0
 public void ShowProductDisclaimerPanel(StoreProduct product)
 {
     if (!(product is IAPProduct) && currencyData.gravitons < product.price)
     {
         iconToast.ShowToast("Not enough Gravitons", gravitonsSprite, 2f);
         return;
     }
     disclaimerPanel.SetActive(true);
     highlightedProduct = product;
 }
Beispiel #2
0
    private IEnumerator ToastCoroutine(ToastScript toast, string message, Sprite sprite, float duration, float delay, bool enqueue)
    {
        yield return(new WaitForSeconds(delay));

        if (enqueue)
        {
            toast.EnqueueToast(message, sprite, duration);
        }
        else
        {
            toast.ShowToast(message, sprite, duration);
        }
    }
Beispiel #3
0
    public void BuyHighlightedProduct()
    {
        currencyData.gravitons -= (int)highlightedProduct.price;
        switch (highlightedProduct.type)
        {
        case StoreProduct.ProductType.GRAVITY_POINT:
            currencyData.gravityPoints += highlightedProduct.amount;
            iconToast.EnqueueToast(highlightedProduct.amount + " Gravity Points purchased", GPSprite, 1.5f);
            break;

        case StoreProduct.ProductType.ASPECT:
            aspectData.UnlockAspect(highlightedProduct.id);
            SaveManager.GetInstance().SavePersistentData(aspectData, SaveManager.ASPECTDATA_PATH);
            GetProductWithID(highlightedProduct.id)?.SetProductState(StoreProduct.ProductState.PURCHASED);
            toast.ShowToast("Aspect purchased: " + aspectData.AspectStringFromId(highlightedProduct.id), null, 2f);
            break;

        case StoreProduct.ProductType.POWER_UP:

            if (highlightedProduct.id.Equals("GRB4"))
            {
                skillsData.gammaRayBurstPoints = 4;
                SaveManager.GetInstance().SavePersistentData(skillsData, SaveManager.SKILLSDATA_PATH);
                GetProductWithID("GRB4")?.SetProductState(StoreProduct.ProductState.CONSUMED);
                iconToast.EnqueueToast("GRB 4 purchased", grbSprite, 2f);
            }
            else if (highlightedProduct.id.Equals("MSU"))
            {
                skillsData.magneticShieldBundleUnlocked = true;
                SaveManager.GetInstance().SavePersistentData(skillsData, SaveManager.SKILLSDATA_PATH);
                GetProductWithID("MSU")?.SetProductState(StoreProduct.ProductState.CONSUMED);
                iconToast.EnqueueToast("Magnetic shield bundle purchased", shieldSprite, 1.5f);
            }
            break;

        default:
            currencyData.gravitons += (int)highlightedProduct.price;
            break;
        }
        SaveManager.GetInstance().SavePersistentData(currencyData, SaveManager.CURRENCY_PATH);
        gravitonsText.text = currencyData.gravitons.ToString();
        disclaimerPanel.SetActive(false);
        highlightedProduct = null;
    }
Beispiel #4
0
    //Skills
    public void UpgradeAntiGravity()
    {
        if (skillsData.antigravityPoints >= PlayerSkillsData.ANTIGRAVITY_MAX_POINTS)
        {
            toast.ShowToast("Already at max level", null, 2f);
            return;
        }

        if (antigravityUpgradeCost <= currencyData.gravityPoints)
        {
            if (skillsData != null)
            {
                skillsData.antigravityPoints++;
                currencyData.gravityPoints -= antigravityUpgradeCost;
                antigravityUpgradeCost      = GameplayMath.GetInstance().GetCostFromInitCost(skillsData.antigravityPoints, INIT_ANTIGRAVITY_COST, GameplayMath.DEFAULT_RATIO);
            }
            SaveManager.GetInstance().SavePersistentData(skillsData, SaveManager.SKILLSDATA_PATH);
            SaveManager.GetInstance().SavePersistentData(currencyData, SaveManager.CURRENCY_PATH);
            UpdateUI();
        }
        else
        {
            toast.ShowToast("Not enough Gravity Points", null, 1.5f);
        }
    }