| 12345678910111213141516171819202122232425 |
- using UnityEngine;
- /// <summary>
- /// Tracks completed level runs for ad pacing. Stored in PlayerPrefs so Reset Save does not clear it.
- /// </summary>
- public static class AdMobEngagement
- {
- public const int MinRoundsBeforeNonRewardedAds = 10;
- const string RoundsPlayedKey = "CrazyFruit.AdMob.RoundsPlayed";
- public static int RoundsPlayed => PlayerPrefs.GetInt(RoundsPlayedKey, 0);
- public static bool NonRewardedAdsEnabled => RoundsPlayed >= MinRoundsBeforeNonRewardedAds;
- /// <summary>Call when a level run ends (win or final loss).</summary>
- public static bool RecordRoundCompleted()
- {
- int before = RoundsPlayed;
- int after = before + 1;
- PlayerPrefs.SetInt(RoundsPlayedKey, after);
- PlayerPrefs.Save();
- return before < MinRoundsBeforeNonRewardedAds && after >= MinRoundsBeforeNonRewardedAds;
- }
- }
|