using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AppodealAds.Monetization.Api;
using AppodealAds.Monetization.Common;
public class AdsManager : MonoBehaviour, IAppodealInitializationListener, IInterstitialAdListener, IRewardedVideoAdListener
{
public static AdsManager Instance;
private const string AppKey = "";
public int BonusesIndex;
private int count;
public bool videoFinished;
double rewardAmount;
string rewardName;
private void Start()
{
Instance = this;
videoFinished = false;
DontDestroyOnLoad(this);
count = 0;
int adTypes = AppodealAdType.Interstitial | AppodealAdType.Banner | AppodealAdType.RewardedVideo | AppodealAdType.Mrec;
Appodeal.Initialize(AppKey, adTypes, this);
Appodeal.SetRewardedVideoCallbacks(this);
Appodeal.Cache(AppodealAdType.Interstitial);
Appodeal.Cache(AppodealAdType.RewardedVideo);
}
public void OnInitializationFinished(List<string> errors) { }
void Update()
{
if (videoFinished)
{
Bonuses.Instance.AdShown(BonusesIndex);
//logic collected bonuses
videoFinished = false;
}
}
private void Initialize(bool isTesting)
{
Appodeal.setTesting(isTesting);
Appodeal.muteVideosIfCallsMuted(true);
//Appodeal.disableWriteExternalStoragePermissionCheck();
Appodeal.disableLocationPermissionCheck();
Appodeal.initialize(APP_KEY, Appodeal.INTERSTITIAL | Appodeal.REWARDED_VIDEO);
Appodeal.setRewardedVideoCallbacks(this);
}
public void ShowInterstitial()
{
count++;
if (count == 5)
{
if (Appodeal.IsLoaded(AppodealAdType.Interstitial))
Appodeal.Show(AppodealShowStyle.Interstitial);
count = 0;
}
}
public void ShowRewarded(int index)
{
Debug.Log("ShowRewarded" + index);
BonusesIndex = index;
if (Appodeal.IsLoaded(AppodealAdType.RewardedVideo))
Appodeal.Show(AppodealShowStyle.RewardedVideo);
}
#region Interstitial
public void onInterstitialClicked()
{
throw new System.NotImplementedException();
}
public void onInterstitialClosed()
{
throw new System.NotImplementedException();
}
public void onInterstitialExpired()
{
throw new System.NotImplementedException();
}
public void onInterstitialFailedToLoad()
{
throw new System.NotImplementedException();
}
public void onInterstitialLoaded(bool isPrecache)
{
throw new System.NotImplementedException();
}
public void onInterstitialShowFailed()
{
throw new System.NotImplementedException();
}
public void onInterstitialShown()
{
throw new System.NotImplementedException();
}
#endregion
#region Rewarded
public void OnRewardedVideoLoaded(bool isPrecache)
{
throw new System.NotImplementedException();
}
public void OnRewardedVideoFailedToLoad()
{
throw new System.NotImplementedException();
}
public void OnRewardedVideoShowFailed()
{
throw new System.NotImplementedException();
}
public void OnRewardedVideoShown()
{
throw new System.NotImplementedException();
}
public void OnRewardedVideoFinished(double amount, string currency)
{
rewardAmount = amount;
rewardName = currency;
videoFinished = true;
}
public void OnRewardedVideoClosed(bool finished)
{
throw new System.NotImplementedException();
}
public void OnRewardedVideoExpired()
{
throw new System.NotImplementedException();
}
public void OnRewardedVideoClicked()
{
throw new System.NotImplementedException();
}
#endregion
#region Interstitial
public void OnInterstitialLoaded(bool isPrecache)
{
throw new System.NotImplementedException();
}
public void OnInterstitialFailedToLoad()
{
throw new System.NotImplementedException();
}
public void OnInterstitialShowFailed()
{
throw new System.NotImplementedException();
}
public void OnInterstitialShown()
{
throw new System.NotImplementedException();
}
public void OnInterstitialClosed()
{
throw new System.NotImplementedException();
}
public void OnInterstitialClicked()
{
throw new System.NotImplementedException();
}
public void OnInterstitialExpired()
{
throw new System.NotImplementedException();
}
#endregion
}