//old method public override void DidRewardUser(RewardBasedVideoAd rewardBasedVideoAd, AdReward reward) { OnRewarded?.Invoke(rewardBasedVideoAd, new MTEventArgs() { RewardAmount = (int)reward.Amount, RewardType = reward.Type }); }
public void UserDidEarnReward(RewardedAd rewardedAd, AdReward reward) { OnRewardedUser?.Invoke(rewardedAd.AdUnitId, new AdMobRewardedEventArgs() { RewardAmount = (int)reward.Amount, RewardType = reward.Type }); }
private void Initialize() { if (this.initialized) { return; } this.adReward = new AdReward(AdvertisementHandler.ExtraCoinsRewardPlacement); AdReward adReward = this.adReward; adReward.OnReady = (Action)Delegate.Combine(adReward.OnReady, new Action(this.OnAdReady)); AdReward adReward2 = this.adReward; adReward2.OnFailed = (Action)Delegate.Combine(adReward2.OnFailed, new Action(this.OnAdFailure)); AdReward adReward3 = this.adReward; adReward3.OnAdFinished = (Action)Delegate.Combine(adReward3.OnAdFinished, new Action(this.OnAdFinished)); AdReward adReward4 = this.adReward; adReward4.OnLoading = (Action)Delegate.Combine(adReward4.OnLoading, new Action(this.OnAdLoading)); AdReward adReward5 = this.adReward; adReward5.OnCancel = (Action)Delegate.Combine(adReward5.OnCancel, new Action(this.OnAdCancel)); AdReward adReward6 = this.adReward; adReward6.OnConfirmationFailed = (Action)Delegate.Combine(adReward6.OnConfirmationFailed, new Action(this.OnAdConfirmationFailed)); this.adReward.Load(); this.initialized = true; }
void offerReward(AdReward reward) { if (reward != null) { reward.OfferReward(); } }
public void WatchAd(AdReward reward = null) { if (!Advertisement.isInitialized) { #if UNITY_IOS Advertisement.Initialize(IOS_ID, true); #endif #if UNITY_ANDROID Advertisement.Initialize(ANDROID_ID, true); #endif } StartCoroutine(showAdWhenReady(reward)); }
private void OnDestroy() { if (this.adReward != null) { AdReward adReward = this.adReward; adReward.OnAdFinished = (Action)Delegate.Remove(adReward.OnAdFinished, new Action(this.OnAdFinished)); AdReward adReward2 = this.adReward; adReward2.OnLoading = (Action)Delegate.Remove(adReward2.OnLoading, new Action(this.OnAdLoading)); AdReward adReward3 = this.adReward; adReward3.OnCancel = (Action)Delegate.Remove(adReward3.OnCancel, new Action(this.OnAdCancelled)); AdReward adReward4 = this.adReward; adReward4.OnFailed = (Action)Delegate.Remove(adReward4.OnFailed, new Action(this.OnAdFailed)); AdReward adReward5 = this.adReward; adReward5.OnReady = (Action)Delegate.Remove(adReward5.OnReady, new Action(this.OnAdReady)); this.adReward.Dispose(); } }
private void InitAdReward() { if (this.adReward == null || this.adReward.Disposed) { this.adReward = new AdReward(AdvertisementHandler.DailyChallengeRevealPlacement); AdReward adReward = this.adReward; adReward.OnAdFinished = (Action)Delegate.Combine(adReward.OnAdFinished, new Action(this.OnAdFinished)); AdReward adReward2 = this.adReward; adReward2.OnLoading = (Action)Delegate.Combine(adReward2.OnLoading, new Action(this.OnAdLoading)); AdReward adReward3 = this.adReward; adReward3.OnCancel = (Action)Delegate.Combine(adReward3.OnCancel, new Action(this.OnAdCancelled)); AdReward adReward4 = this.adReward; adReward4.OnFailed = (Action)Delegate.Combine(adReward4.OnFailed, new Action(this.OnAdFailed)); AdReward adReward5 = this.adReward; adReward5.OnReady = (Action)Delegate.Combine(adReward5.OnReady, new Action(this.OnAdReady)); AdReward adReward6 = this.adReward; adReward6.OnConfirmationFailed = (Action)Delegate.Combine(adReward6.OnConfirmationFailed, new Action(this.OnConfirmationFailed)); } }
protected override void Start() { base.Start(); this.adReward = new AdReward(AdvertisementHandler.LevelRewardVideoPlacement); AdReward adReward = this.adReward; adReward.OnAdFinished = (Action)Delegate.Combine(adReward.OnAdFinished, new Action(this.OnAdFinished)); AdReward adReward2 = this.adReward; adReward2.OnLoading = (Action)Delegate.Combine(adReward2.OnLoading, new Action(this.OnAdLoading)); AdReward adReward3 = this.adReward; adReward3.OnCancel = (Action)Delegate.Combine(adReward3.OnCancel, new Action(this.OnAdCancelled)); AdReward adReward4 = this.adReward; adReward4.OnFailed = (Action)Delegate.Combine(adReward4.OnFailed, new Action(this.OnAdFailed)); AdReward adReward5 = this.adReward; adReward5.OnReady = (Action)Delegate.Combine(adReward5.OnReady, new Action(this.OnAdReady)); this.adReward.Load(); base.onOpen += delegate() { if (this.adReward != null) { this.adReward.Load(); } }; base.onClose += delegate() { if (this.adReward != null) { this.adReward.Stall(); } }; GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(WPFMonoBehaviour.gameData.m_videoNotFoundDialog); gameObject.transform.position = WPFMonoBehaviour.hudCamera.transform.position + new Vector3(0f, 0f, 1f); this.videoNotFoundDialog = gameObject.GetComponent <TextDialog>(); this.videoNotFoundDialog.Close(); }
private void Initialize() { GameConfigurationManager instance = Singleton <GameConfigurationManager> .Instance; instance.OnHasData = (Action)Delegate.Remove(instance.OnHasData, new Action(this.Initialize)); string value = Singleton <GameConfigurationManager> .Instance.GetValue <string>("free_crate_ad_reward", "LootCrateType"); try { this.reward = (LootCrateType)Enum.Parse(typeof(LootCrateType), value); } catch (ArgumentException) { this.reward = LootCrateType.Cardboard; } this.adReward = new AdReward(AdvertisementHandler.FreeLootCratePlacement); AdReward adReward = this.adReward; adReward.OnAdFinished = (Action)Delegate.Combine(adReward.OnAdFinished, new Action(this.OnAdFinished)); AdReward adReward2 = this.adReward; adReward2.OnCancel = (Action)Delegate.Combine(adReward2.OnCancel, new Action(this.OnAdCancel)); AdReward adReward3 = this.adReward; adReward3.OnConfirmationFailed = (Action)Delegate.Combine(adReward3.OnConfirmationFailed, new Action(this.OnConfirmationFailed)); AdReward adReward4 = this.adReward; adReward4.OnFailed = (Action)Delegate.Combine(adReward4.OnFailed, new Action(this.OnAdFailed)); AdReward adReward5 = this.adReward; adReward5.OnLoading = (Action)Delegate.Combine(adReward5.OnLoading, new Action(this.OnAdLoading)); AdReward adReward6 = this.adReward; adReward6.OnReady = (Action)Delegate.Combine(adReward6.OnReady, new Action(this.OnAdReady)); AdReward adReward7 = this.adReward; adReward7.OnAdPlayFailed = (Action)Delegate.Combine(adReward7.OnAdPlayFailed, new Action(this.OnAdPlayFailed)); this.adReward.Load(); }
IEnumerator showAdWhenReady(AdReward reward = null) { while (!Advertisement.IsReady(AD_TYPE)) { yield return(null); } Advertisement.Show(AD_TYPE, new ShowOptions() { resultCallback = result => { switch (result) { case ShowResult.Finished: offerReward(reward); break; case ShowResult.Failed: offerReward(reward); break; } } }); }
public override void DidRewardUser(RewardBasedVideoAd rewardBasedVideoAd, AdReward reward) { Console.WriteLine("rewarded"); }
private void Awake() { Instance = this; }