public void AddCoins_ValidNominal_AddsToPile() { var w = new Wallet(new uint[] { 1, 3 }); w.AddCoins(3, 10); w.AddCoins(3, 12); w.AddCoins(1, 1); Assert.AreEqual(22, w[3].Count); Assert.AreEqual(1, w[1].Count); }
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args) { // A non consumable product has been purchased by this user. if (String.Equals(args.purchasedProduct.definition.id, removeAds, StringComparison.Ordinal)) { //User removed ads. Debug.Log("User removed ads"); list.GetChild(0).GetChild(1).gameObject.SetActive(false); list.GetChild(0).GetChild(2).gameObject.SetActive(true); AdBanner.DestroyBanner(); PlayerPrefs.SetInt("DisableAds", 1); } // A consumable product has been purchased by this user. else if (String.Equals(args.purchasedProduct.definition.id, pinchOfCoins, StringComparison.Ordinal)) { //User got 10000 coins. Debug.Log("User got 10000 coins"); Wallet.AddCoins(10000); Wallet.CoinBlast(); } // A non consumable product has been purchased by this user. else if (String.Equals(args.purchasedProduct.definition.id, rocketPack, StringComparison.Ordinal)) { //User bought rocket guns. Debug.Log("User got rocket guns pack"); list.GetChild(3).GetChild(1).gameObject.SetActive(false); list.GetChild(3).GetChild(2).gameObject.SetActive(true); PlayerPrefs.SetInt("RocketPackBought", 1); PlayerPrefs.SetInt("GunBought9", 1); PlayerPrefs.SetInt("GunBought10", 1); } // A non consumable product has been purchased by this user. else if (String.Equals(args.purchasedProduct.definition.id, sniperPack, StringComparison.Ordinal)) { //User bought sniper pack. Debug.Log("User got sniper guns pack"); list.GetChild(2).GetChild(1).gameObject.SetActive(false); list.GetChild(2).GetChild(2).gameObject.SetActive(true); PlayerPrefs.SetInt("SniperPackBought", 1); PlayerPrefs.SetInt("GunBought4", 1); PlayerPrefs.SetInt("GunBought8", 1); } // Or ... an unknown product has been purchased by this user. Fill in additional products here.... else { Debug.Log(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id)); } // Return a flag indicating whether this product has completely been received, or if the application needs // to be reminded of this purchase at next app launch. Use PurchaseProcessingResult.Pending when still // saving purchased products to the cloud, and when that save is delayed. return(PurchaseProcessingResult.Complete); }
//If pressed claim button with no ads. public void Claim() { //Add coins to player wallet. Wallet.AddCoins(100); Wallet.CoinBlast(); //Reset timer. Timer.giftTimer = 1800; //Reset gift image and animation. giftButton.GetComponent <Image>().color = Color.white; transform.GetChild(4).GetChild(0).GetComponent <Image>().color = Color.white; //Update achievements stats. PlayerPrefs.SetInt("CollectGifts", (PlayerPrefs.GetInt("CollectGifts") + 1)); }
IEnumerator StartVideoAd() { yield return(new WaitForSeconds(0.5f)); //Show reward video. #if UNITY_ADS Advertisement.Show("rewardedVideo"); //Add x8 more coins to players wallet. var temp = Wallet.coins; Wallet.removeCoins(temp - Wallet.startCoins); Wallet.AddCoins((temp - Wallet.startCoins) * 8); //Start exiting. StartCoroutine(ExitReward()); #endif }
IEnumerator StartVideoAd() { yield return(new WaitForSeconds(0.5f)); //Show ad. #if UNITY_ADS Advertisement.Show("rewardedVideo"); //Add coins to player wallet. Wallet.AddCoins(100); Wallet.CoinBlast(); //Reset gift timer. Timer.giftTimer = 1800; //Update achievements stats. PlayerPrefs.SetInt("CollectGifts", (PlayerPrefs.GetInt("CollectGifts") + 1)); FadeOut(); #endif }
void OnTriggerEnter2D(Collider2D col) { //If gun touched coin. if (col.tag == "GunUI") { //Add coin to wallet. Wallet.AddCoins(1); //Add coin to Achievements stats. PlayerPrefs.SetInt("CollectCoins", (PlayerPrefs.GetInt("CollectCoins") + 1)); coinCount++; //If collected 10 coins in one session then first achievement has been reached. if (coinCount == 10 && PlayerPrefs.GetInt("OneSessionCoins") < 10) { PlayerPrefs.SetInt("OneSessionCoins", 10); } //If collected 10 coins in one session then second achievement has been reached. else if (coinCount == 25 && PlayerPrefs.GetInt("OneSessionCoins") < 25) { PlayerPrefs.SetInt("OneSessionCoins", 25); } //If collected 10 coins in one session then third achievement has been reached. else if (coinCount == 50 && PlayerPrefs.GetInt("OneSessionCoins") < 50) { PlayerPrefs.SetInt("OneSessionCoins", 50); } //If playing in challenge mode. if (ChallengeMenu.challengeActive[3]) { //Update challenge stats. Coroutines.AchieveChallenge(coinCount, 25, 50, 100); } //Start destroy coroutine. StartCoroutine(CoinDestroy()); } }