diff options
Diffstat (limited to 'Penguloon/AdManager.cs')
| -rw-r--r-- | Penguloon/AdManager.cs | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/Penguloon/AdManager.cs b/Penguloon/AdManager.cs index 2537a9d..65f464c 100644 --- a/Penguloon/AdManager.cs +++ b/Penguloon/AdManager.cs @@ -22,22 +22,46 @@ namespace Penguloon public static class AdManager { public static InterstitialAd GameOverAd { get; set; } + public static bool GameOverAdLoaded { get; set; } = false; public static void Load(Main main) { - return; + LoadGameOverAd(main); + } + + private static void LoadGameOverAd(Main main) + { + if (GameOverAdLoaded) return; GameOverAd = new InterstitialAd(main.Context); GameOverAd.AdUnitId = "ca-app-pub-5292616698166001/6013632836"; - GameOverAd.LoadAd(new AdRequest.Builder().Build()); + var adRequest = new AdRequest.Builder().Build(); + GameOverAd.AdListener = new AdListener(main.Activity__); + GameOverAd.LoadAd(adRequest); } public static void ShowGameOverAd() { - return; - - if (GameOverAd.IsLoaded) + if (GameOverAdLoaded) GameOverAd.Show(); + + GameOverAdLoaded = false; + } + + class AdListener : Android.Gms.Ads.AdListener + { + Activity activity; + + public AdListener(Activity activity) + { + this.activity = activity; + } + + public override void OnAdLoaded() + { + base.OnAdLoaded(); + GameOverAdLoaded = true; + } } } }
\ No newline at end of file |
