using UnityEngine;
///
/// Tracks completed level runs for ad pacing. Stored in PlayerPrefs so Reset Save does not clear it.
///
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;
/// Call when a level run ends (win or final loss).
public static bool RecordRoundCompleted()
{
int before = RoundsPlayed;
int after = before + 1;
PlayerPrefs.SetInt(RoundsPlayedKey, after);
PlayerPrefs.Save();
return before < MinRoundsBeforeNonRewardedAds && after >= MinRoundsBeforeNonRewardedAds;
}
}