diff options
author | chai <chaifix@163.com> | 2020-12-30 20:59:04 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-12-30 20:59:04 +0800 |
commit | e9ea621b93fbb58d9edfca8375918791637bbd52 (patch) | |
tree | 19ce3b1c1f2d51eda6878c9d0f2c9edc27f13650 /Client/Assembly-CSharp/GoogleMobileAds/Api/RewardedAd.cs |
+init
Diffstat (limited to 'Client/Assembly-CSharp/GoogleMobileAds/Api/RewardedAd.cs')
-rw-r--r-- | Client/Assembly-CSharp/GoogleMobileAds/Api/RewardedAd.cs | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/GoogleMobileAds/Api/RewardedAd.cs b/Client/Assembly-CSharp/GoogleMobileAds/Api/RewardedAd.cs new file mode 100644 index 0000000..48a43ff --- /dev/null +++ b/Client/Assembly-CSharp/GoogleMobileAds/Api/RewardedAd.cs @@ -0,0 +1,97 @@ +using System; +using System.Reflection; +using GoogleMobileAds.Common; + +namespace GoogleMobileAds.Api +{ + public class RewardedAd + { + public event EventHandler<EventArgs> OnAdLoaded; + + public event EventHandler<AdErrorEventArgs> OnAdFailedToLoad; + + public event EventHandler<AdErrorEventArgs> OnAdFailedToShow; + + public event EventHandler<EventArgs> OnAdOpening; + + public event EventHandler<EventArgs> OnAdClosed; + + public event EventHandler<Reward> OnUserEarnedReward; + + private IRewardedAdClient client; + + public RewardedAd(string adUnitId) + { + MethodInfo method = Type.GetType("GoogleMobileAds.GoogleMobileAdsClientFactory,Assembly-CSharp").GetMethod("BuildRewardedAdClient", BindingFlags.Static | BindingFlags.Public); + this.client = (IRewardedAdClient)method.Invoke(null, null); + this.client.CreateRewardedAd(adUnitId); + this.client.OnAdLoaded += delegate(object sender, EventArgs args) + { + if (this.OnAdLoaded != null) + { + this.OnAdLoaded(this, args); + } + }; + this.client.OnAdFailedToLoad += delegate(object sender, AdErrorEventArgs args) + { + if (this.OnAdFailedToLoad != null) + { + this.OnAdFailedToLoad(this, args); + } + }; + this.client.OnAdFailedToShow += delegate(object sender, AdErrorEventArgs args) + { + if (this.OnAdFailedToShow != null) + { + this.OnAdFailedToShow(this, args); + } + }; + this.client.OnAdOpening += delegate(object sender, EventArgs args) + { + if (this.OnAdOpening != null) + { + this.OnAdOpening(this, args); + } + }; + this.client.OnAdClosed += delegate(object sender, EventArgs args) + { + if (this.OnAdClosed != null) + { + this.OnAdClosed(this, args); + } + }; + this.client.OnUserEarnedReward += delegate(object sender, Reward args) + { + if (this.OnUserEarnedReward != null) + { + this.OnUserEarnedReward(this, args); + } + }; + } + + public void LoadAd(AdRequest request) + { + this.client.LoadAd(request); + } + + public bool IsLoaded() + { + return this.client.IsLoaded(); + } + + public void Show() + { + this.client.Show(); + } + + public void SetServerSideVerificationOptions(ServerSideVerificationOptions serverSideVerificationOptions) + { + this.client.SetServerSideVerificationOptions(serverSideVerificationOptions); + } + + public string MediationAdapterClassName() + { + return this.client.MediationAdapterClassName(); + } + } +} |