I'm trying to make it so that you can pass the level by watching rewarded ad.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
using GoogleMobileAds;
using System;
public class AdManager : MonoBehaviour
{
public GameManager gm;
public RewardBasedVideoAd rewardVideo;
public int adHasBeenShown;
public void Start()
{
adHasBeenShown = 0;
this.rewardVideo = RewardBasedVideoAd.Instance;
rewardVideo.OnAdRewarded += HandleRewardVideoRewarded;
rewardVideo.OnAdFailedToLoad += HandleOnAdFailedToLoad;
rewardVideo.OnAdClosed += HandleRewardVideoClosed;
this.RequestRewardVideoo();
}
public void RequestRewardVideoo()
{
#if UNITY_ANDROID
string rewardedAdID = "ca-app-pub-3940256099942544/5224354917";
#else
string rewardedAdID = "unexpected_platform";
#endif
AdRequest request = new AdRequest.Builder().Build();
this.rewardVideo.LoadAd(request, rewardedAdID);
}
public void OnCompleteButtonPressed()
{
if (rewardVideo.IsLoaded())
{
rewardVideo.Show();
}
}
public void HandleRewardVideoRewarded(object sender, Reward args)
{
gm.CompleteLevel();
}
public void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
{
this.RequestRewardVideoo();
}
public void HandleRewardVideoClosed(object sender, EventArgs args)
{
this.RequestRewardVideoo();
}
}
gm.CompleteLevel() looks like this:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;
using UnityEngine.UI;
using DG.Tweening;
public class GameManager : MonoBehaviour {
public void CompleteLevel()
{
foreach (GameObject go in AllSymbols)
{
go.GetComponent().canMove = true;
go.GetComponentInChildren().color = new Color32(255, 255, 255, 255);
}
foreach (GameObject go in UncorrectSymbols)
{
go.GetComponentInParent
↧