private void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); MobileAds.Initialize(appID); if (useTestAdsID) { extraAttemptID = "ca-app-pub-3940256099942544/5224354917"; timedRewardID = "ca-app-pub-3940256099942544/5224354917"; } else { extraAttemptID = "ca-app-pub-2239617021238574/7600245152"; //TODO set timedRewardID = "ca-app-pub-2239617021238574/2587152628"; } StartCoroutine(LoadAd_C()); }
private IEnumerator CheckAd_C() { while (true) { if (!gameMode.attemptUsed) { if (GoogleAdsManager.GetInstance().IsRewardedAdLoaded(GoogleAdsManager.RewardedAdType.EXTRA_ATTEMPT)) { if (gameMode.isGameOver) { adButton.SetActive(true); loadingAdText.gameObject.SetActive(false); } } else { if (gameMode.isGameOver) { adButton.SetActive(false); loadingAdText.gameObject.SetActive(true); } } } else { adButton.SetActive(false); loadingAdText.gameObject.SetActive(false); } yield return(new WaitForSeconds(3f)); } }
void Awake() { if (Instance == null) { Instance = this; } else if (Instance != this) { Destroy(gameObject); } }
private IEnumerator DailyReward_C() { servData.lastAccess = System.DateTime.Now; int difference = (int)(servData.lastAccess - servData.lastRewardClaimed).TotalSeconds; //yield return new WaitForSecondsRealtime(0.1f); while (true) { if (difference < PersistentPrefs.GetInstance().timeDelay) { gravitonsIcon.SetActive(true); adIcon.SetActive(false); rewardTimeText.text = SharedUtilities.GetInstance().GetTimeStringFromSeconds(PersistentPrefs.GetInstance().timeDelay - difference); rewardTimeText.gameObject.SetActive(true); costText.text = PersistentPrefs.GetInstance().gravitonsCost.ToString(); rewardReady = false; } else { if (GoogleAdsManager.GetInstance().IsRewardedAdLoaded(GoogleAdsManager.RewardedAdType.TIMED_REWARD)) { gravitonsIcon.SetActive(false); adIcon.SetActive(true); rewardTimeText.gameObject.SetActive(false); rewardReady = true; } else { rewardTimeText.gameObject.SetActive(true); rewardTimeText.text = "Loading ad..."; costText.text = PersistentPrefs.GetInstance().gravitonsCost.ToString(); rewardReady = false; } } yield return(new WaitForSecondsRealtime(1f)); difference = (int)(System.DateTime.Now - servData.lastRewardClaimed).TotalSeconds; } }
public void GetDailyReward() { if (rewardReady) { rewardReady = false; GoogleAdsManager.GetInstance().ShowRewardedAd(GoogleAdsManager.RewardedAdType.TIMED_REWARD); if (Application.isEditor) { EarnReward(true); } } else { currencyData = SaveManager.GetInstance().LoadPersistentData(SaveManager.CURRENCY_PATH).GetData <CurrencyData>(); if (currencyData.gravitons < PersistentPrefs.GetInstance().gravitonsCost) { toast.EnqueueToast("Not enough gravitons", null, 1.5f); return; } OpenConfirmPanel(true); } }
public void ShowRewardedAd() { GoogleAdsManager.GetInstance().ShowRewardedAd(GoogleAdsManager.RewardedAdType.EXTRA_ATTEMPT); }
private void OnDisable() { GoogleAdsManager.GetInstance().UnsubscribeToRewardClaimed(AdRewardEarned); GoogleIAPManager.GetInstance().UnsubscribeToProductPurchased(IapProductPurchased); }
private void Awake() { instance = this; }