public void AddCoin() { // Play sound SoundManager.PlayButtonOpen(); // Create popup GameObject buyCoinPopup = _buyCoinPopupPrefab.CreateUI(_canvas.transform); BuyCoinPopupScript script = buyCoinPopup.GetComponent <BuyCoinPopupScript>(); if (script != null) { script.Show(); } }
public void BuyMana() { // Play sound SoundManager.PlayButtonClick(); // Close popup Close(); UserData userData = UserData.Instance; int coin = Settings.CoinToBuyFullMana; if (userData.Coin >= coin) { if (_buyCallback != null) { _buyCallback(); } else { // Play sound SoundManager.Instance.PlaySound(SoundID.Coin); // Decrease coin NotificationManager.CoinChanged(UserData.Instance.Coin - coin); // Increase mana NotificationManager.ManaChanged(Settings.MaxMana); } } else { if (_buyCoinPopupPrefab != null) { GameObject buyCoinPopup = _buyCoinPopupPrefab.CreateUI(transform.parent); BuyCoinPopupScript script = buyCoinPopup.GetComponent <BuyCoinPopupScript>(); if (script != null) { script.Show(); } } else { //Log.Debug("Not enough coin!"); } } }
public void BuyMana() { // Play sound SoundManager.PlayButtonClick(); // Close popup //Close(); UserData userData = UserData.Instance; if (userData.Coin >= Settings.CoinToBuyFullMana) { Close(); if (_buyCallback != null) { _buyCallback(); } } else { if (_buyCoinPopupPrefab != null) { GameObject buyCoinPopup = _buyCoinPopupPrefab.CreateUI(transform.parent); BuyCoinPopupScript script = buyCoinPopup.GetComponent <BuyCoinPopupScript>(); if (script != null) { script.Show(); } } else { //Log.Debug("Not enough coin!"); } } }
public void Buy() { // Play sound SoundManager.PlayButtonClick(); // Hide popup HidePopup(); // Get coin int coins = _type.GetBuyCoin(); // Check if enough coins if (UserData.Instance.Coin >= coins) { // Get quantity int quantity = _type.GetBuyQuantity(); // Increase booster if (_type.IsUndo()) { UserData.Instance.Undo += quantity; Manager.Instance.analytics.LogEvent("Main Game", "Buy Booster", "Undo", 1); } else if (_type.IsHint()) { UserData.Instance.Hint += quantity; Manager.Instance.analytics.LogEvent("Main Game", "Buy Booster", "Hint", 1); } else if (_type.IsHammer()) { UserData.Instance.Hammer += quantity; Manager.Instance.analytics.LogEvent("Main Game", "Buy Booster", "Hammer", 1); } else if (_type.IsDeploy()) { UserData.Instance.Deploy += quantity; Manager.Instance.analytics.LogEvent("Main Game", "Buy Booster", "Deploy", 1); } // Decrease coins UserData.Instance.Coin -= coins; } else { if (_buyCoinPopupPrefab != null) { GameObject buyCoinPopup = _buyCoinPopupPrefab.CreateUI(transform.parent); BuyCoinPopupScript script = buyCoinPopup.GetComponent <BuyCoinPopupScript>(); if (script != null) { script.Show(); } } else { //Log.Debug("Not enough coin!"); } } }