using System;
using UnityEngine;

public sealed class AdManager : SingletonMonoBehaviour<AdManager> {

    //-- ironSource --//
#if UNITY_IOS
    private static readonly string IRONSOURCE_APP_KEY = "";
#else
    private static readonly string IRONSOURCE_APP_KEY = "";
#endif

    void Awake(){
#if DEVELOPMENT_BUILD
        // IronSource.Agent.validateIntegration ();
        // IronSource.Agent.setAdaptersDebug(true);
#endif
        // IronSource.Agent.init (IRONSOURCE_APP_KEY);
    }

    void Start(){
        LoadBannerAds();
        ShowBannerAd();
    }

    void Update (){
    }

    void OnApplicationPause(bool isPaused) {
        // IronSource.Agent.onApplicationPause(isPaused);
    }

    //-- Banners Ads --//

    public void LoadBannerAds(){
        // IronSource.Agent.loadBanner(IronSourceBannerSize.SMART, IronSourceBannerPosition.BOTTOM);

    }
    public void ShowBannerAd(){
        // IronSource.Agent.displayBanner();
    }
    public void HideBanner(){
        // IronSource.Agent.hideBanner();
    }


    public bool IsLoadedRewardVideo(){
#if DEVELOPMENT_BUILD || UNITY_EDITOR
        return !UsayaStorageManager.LoadOrDefault(UsayaStorageFilename.Settings_Data, "DebugAlwaysVideoFailToLoad", false);
#endif
        return true;
// #if UNITY_EDITOR
//         return true;
// #else
//         return IronSource.Agent.isRewardedVideoAvailable();
// #endif
    }
    public void ShowRewardVideo(Action<bool> callback){
        callback(true);
// #if UNITY_EDITOR
//         callback(true);
// #else
//         _rewardAdCallback = callback;
//         if(_rewardAdCallback == null){
//             return;
//         }else if(IsLoadedRewardVideo()){
//             _rewardAdOpen = false;
//             _rewardAdFinish = false;
//             _rewardAdClose = false;
//     		_async_frame_count = 0;
//             IronSource.Agent.showRewardedVideo();
//         }else{
//             _rewardAdCallback(false);
//         }
// #endif
    }
}