Example #1
0
    public static void Purchased(string sku, string token, System.Action nextTask)
    {
        var pack = GlobalConfig.Shop.GetPackage(sku);

        if (pack == null)
        {
            nextTask?.Invoke();
            return;
        }

        Profile.EarnGems(pack.gems);
        Profile.Bombs    += pack.bombs;
        Profile.Hammers  += pack.hammers;
        Profile.Missiles += pack.missiles;

        Game.Instance.OpenPopup <Popup_Rewards>().Setup(0, pack.gems, pack.bombs, pack.hammers, pack.missiles, true, false, nextTask);

        PurchaseSystem.Consume(pack.sku, (success, msg) =>
        {
            if (success)
            {
                GlobalAnalytics.NewBuisinessEvent(Online.Purchase.Provider.Market, pack.sku, pack.price, token);
                Online.Stats.Set(GlobalConfig.Instance.version, Profile.Gems, Profile.Skill, Profile.GetLevelsPassed(), r => { });
            }
        });

        GlobalAnalytics.SourceGem(pack.gems, pack.sku.Replace("ameza_", ""));
    }
Example #2
0
 private void InitializeGame()
 {
     if (initialized)
     {
         return;
     }
     PurchaseSystem.Initialize(GlobalConfig.Instance.cafeBazaarKey, GlobalConfig.Configs.updateUrl, (success, msg) => Debug.Log("Purchase system initialized: " + success + " " + msg));
     gameManager.OpenState <State_MainMenu>();
 }
Example #3
0
    public void OnItemClick(int index)
    {
        var item = gameManager.shopItems[index];

        if (item == null)
        {
            return;
        }

        PurchaseSystem.Purchase(PurchaseProvider.Bazaar, item.sku, (success, msg) =>
        {
            if (success)
            {
                purchaseditem = item;
                PurchaseSystem.Consume();
                StartCoroutine(AddGold(item.gold));
#if DATABEEN
                DataBeen.SendPurchaseData(item.sku, msg);
#endif
            }
        });
    }
Example #4
0
    private void Start()
    {
        musicToggle.isOn = AudioManager.MusicVolume < 1;
        soundToggle.isOn = AudioManager.SoundVolume < 1;
        musicToggle.onValueChanged.AddListener((on) => AudioManager.MusicVolume = on ? 0 : 100);
        soundToggle.onValueChanged.AddListener((on) => AudioManager.SoundVolume = on ? 0 : 100);

        resetButton.onClick.AddListener(() => Game.Instance.OpenPopup <Popup_Confirm>().Setup(111061, true, true, yes =>
        {
            if (yes)
            {
                Profile.Reset();
            }
        }));

        surveyButton.onClick.AddListener(() => Application.OpenURL(GlobalConfig.Socials.contactSurveyUrl));

        supportButton.onClick.AddListener(() => SocialAndSharing.SendEmail(
                                              GlobalConfig.Socials.contactEmailUrl,
                                              "Support - " + Application.identifier + " - " + Application.version,
                                              "OS:" + SystemInfo.operatingSystem + "|<br>Model:" + SystemInfo.deviceModel + "|<br>Username:"******"|<br>DeviceId:" + Core.DeviceId + "|<br>Group:" + GlobalConfig.Group + "|_____________________<br><br><br><br>"));

        purchasedButton.onClick.AddListener(() =>
        {
            Loading.Show();
            PurchaseSystem.QueryPurchases(PurchaseProvider.Market, (success, json) =>
            {
                Loading.Hide();
                if (success)
                {
                    var data = JsonUtility.FromJson <PurchasedData>(json);
                    CheckPurchasedList(data, 0);
                }
            });
        });

        UiShowHide.ShowAll(transform);
    }
Example #5
0
    public UiShopItem Setup(string sku, System.Action <bool> onClick = null)
    {
        pack = GlobalConfig.Shop.GetPackage(sku);
        if (pack == null)
        {
            return(this);
        }

        images.SetActiveChild(pack.image);
        if (title)
        {
            title.SetText(pack.title);
        }
        if (gemsLabel)
        {
            gemsLabel.SetFormatedText(pack.gems);
        }
        if (bombLabel)
        {
            bombLabel.SetFormatedText(pack.bombs);
        }
        if (hammerLabel)
        {
            hammerLabel.SetFormatedText(pack.hammers);
        }
        if (missileLabel)
        {
            missileLabel.SetFormatedText(pack.missiles);
        }
        if (priceLabel)
        {
            priceLabel.SetFormatedText(pack.price);
        }
        if (lastPriceLabel)
        {
            lastPriceLabel.SetFormatedText(pack.lastPrice);
        }
        if (discountLabel)
        {
            if (pack.discount > 0)
            {
                discountLabel.SetFormatedText(pack.discount);
            }
            else
            {
                discountLabel.transform.parent.gameObject.SetActive(false);
            }
        }

        button.onClick.AddListener(() =>
        {
            button.SetInteractable(false);
            PurchaseSystem.Purchase(PurchaseProvider.Market, sku, (succeed, token) =>
            {
                if (succeed)
                {
                    Purchased(sku, token, () => onClick?.Invoke(true));
                }
                else
                {
                    onClick?.Invoke(false);
                }

                button.SetInteractable(true);
            });
        });

        return(this);
    }