I'm implementing reward based video ads in my game using Google Admob. There are two functions that provide the reward. One is a ReceiveLife() function where once the player dies, if they click on the revive button the game restarts and the score is set to score before the player dies instead of 0. The other function is ReceivePoints(), where if the player clicks on the add points button, they are rewarded with 100 extra points. I looked at the documentation provided in google admob regarding loading multiple rewarded ads, but I'm unsure of how to go about calling these two functions in the "HandleRewardedAdClosed" function. Here is the code that works for only function (ReceiveLife()):
public class AdScript : MonoBehaviour
{
string Video_Ad_Id = "ca-app-pub-3940256099942544/5224354917";
private RewardedAd rewardedAd;
void Start()
{
MobileAds.Initialize(initStatus => { });
RequestRewardBasedVideo();
}
public void RequestRewardBasedVideo()
{
this.rewardedAd = new RewardedAd(Video_Ad_Id);
this.rewardedAd.OnAdLoaded += HandleRewardedAdLoaded;
this.rewardedAd.OnAdFailedToLoadOnUserEarnedReward += HandleRewardedAdFailedToLoad;HandleUserEarnedReward;
this.rewardedAd.OnAdOpening += HandleRewardedAdOpening;
this.rewardedAd.OnAdFailedToShowOnAdClosed += HandleRewardedAdFailedToShow;HandleRewardedAdClosed;
// Other event thishooks.rewardedAd.OnUserEarnedReward += HandleUserEarnedReward; .
this.rewardedAd.OnAdClosed += HandleRewardedAdClosed;
AdRequest request = new AdRequest.Builder().Build();
this.rewardedAd.LoadAd(request);
}
public void ShowVideoRewardAd()
{
if (this.rewardedAd.IsLoaded())
{
this.rewardedAd.Show();
}
}
.
.
.
.
public void HandleRewardedAdClosed(object sender, EventArgs args)
{
this.RequestRewardBasedVideo();
}
public void HandleUserEarnedReward(object sender, Reward args)
{
GameManager.instance.ReceiveLife();
}
}
How do I call two rewarded functions in the HandleUserEarnedReward() function above. Can someone please help?