157 lines
9.0 KiB
C#
157 lines
9.0 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
namespace WZ
|
|
{
|
|
public struct AdPriceInfo
|
|
{
|
|
public double MaxPrice;
|
|
public double AdmobPrice;
|
|
public double BigoPrice;
|
|
public double KwaiPrice;
|
|
public string ToponAdUnitId;
|
|
|
|
public AdPriceInfo(double maxPrice, double admobPrice, double bigoPrice, double kwaiPrice,string toponAdUnitId)
|
|
{
|
|
MaxPrice = maxPrice;
|
|
AdmobPrice = admobPrice;
|
|
BigoPrice = bigoPrice;
|
|
KwaiPrice = kwaiPrice;
|
|
ToponAdUnitId = toponAdUnitId;
|
|
}
|
|
}
|
|
|
|
public static class AdsBidResult
|
|
{
|
|
private static object m_toponObj = "m_toponObj";
|
|
private static object m_maxObj = "m_maxObj";
|
|
private static object m_admobObj = "m_admobObj";
|
|
private static object m_bigoObj = "m_bigoObj";
|
|
private static object m_kwaiObj = "m_kwaiObj";
|
|
|
|
private static object m_toponRewardObj = "m_toponRewardObj";
|
|
private static object m_toponInterstitialObj = "m_toponInterstitialObj";
|
|
private static object m_rewardObj = "m_rewardObj";
|
|
private static object m_interstitialObj = "m_interstitialObj";
|
|
private static object m_fullNativeObj = "m_fullNativeObj";
|
|
|
|
public static PlatformType GetPlatformType(AdPriceInfo priceInfo)
|
|
{
|
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
|
using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
|
|
{
|
|
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
|
|
AndroidJavaObject toponCustomContentInfo = new AndroidJavaObject("com.thinkup.core.api.TUCustomContentInfo", priceInfo.ToponAdUnitId, m_toponObj);
|
|
AndroidJavaObject admobCustomContentInfo = new AndroidJavaObject("com.thinkup.core.api.TUCustomContentInfo", priceInfo.AdmobPrice * 1000, m_admobObj);
|
|
AndroidJavaObject maxCustomContentInfo = new AndroidJavaObject("com.thinkup.core.api.TUCustomContentInfo", priceInfo.MaxPrice * 1000, m_maxObj);
|
|
AndroidJavaObject bigoCustomContentInfo = new AndroidJavaObject("com.thinkup.core.api.TUCustomContentInfo", priceInfo.BigoPrice * 1000, m_bigoObj);
|
|
AndroidJavaObject kwaiCustomContentInfo = new AndroidJavaObject("com.thinkup.core.api.TUCustomContentInfo", priceInfo.KwaiPrice * 1000, m_kwaiObj);
|
|
|
|
AndroidJavaObject atCustomContentInfoList = new AndroidJavaObject("java.util.ArrayList");
|
|
atCustomContentInfoList.Call<bool>("add", toponCustomContentInfo);
|
|
atCustomContentInfoList.Call<bool>("add", admobCustomContentInfo);
|
|
atCustomContentInfoList.Call<bool>("add", maxCustomContentInfo);
|
|
atCustomContentInfoList.Call<bool>("add", bigoCustomContentInfo);
|
|
atCustomContentInfoList.Call<bool>("add", kwaiCustomContentInfo);
|
|
AndroidJavaClass sdkGlobalSetting = new AndroidJavaClass("com.thinkup.core.api.TUSDKGlobalSetting");
|
|
AndroidJavaObject maxPriceCustomContentInfo = sdkGlobalSetting.CallStatic<AndroidJavaObject>("customContentReviewResult", atCustomContentInfoList);
|
|
|
|
string customContentString = maxPriceCustomContentInfo.Get<string>("customContentString");
|
|
double customContentDouble = maxPriceCustomContentInfo.Get<double>("customContentDouble");
|
|
AndroidJavaObject customContentObject = maxPriceCustomContentInfo.Get<AndroidJavaObject>("customContentObject");
|
|
|
|
string customContentObjectString = customContentObject != null ? customContentObject.Call<string>("toString") : "null";
|
|
LoggerUtils.Debug("[AdsBidResult] maxPrice: " + priceInfo.MaxPrice * 1000 + " bigoPrice: " + priceInfo.BigoPrice * 1000 + " admobPrice: " + priceInfo.AdmobPrice * 1000 + " kwaiPrice: " + priceInfo.KwaiPrice * 1000 + " toponAdUnitId: " + priceInfo.ToponAdUnitId);
|
|
LoggerUtils.Debug("[AdsBidResult] final maxPriceCustomContentInfo: " + customContentString + " double: " + customContentDouble + " object:" + customContentObjectString);
|
|
if (customContentObjectString.Equals(m_toponObj))
|
|
{
|
|
return PlatformType.Topon;
|
|
}
|
|
else if (customContentObjectString.Equals(m_maxObj))
|
|
{
|
|
return PlatformType.AppLovin;
|
|
}
|
|
else if (customContentObjectString.Equals(m_admobObj))
|
|
{
|
|
return PlatformType.Admob;
|
|
}
|
|
else if (customContentObjectString.Equals(m_bigoObj))
|
|
{
|
|
return PlatformType.Bigo;
|
|
}
|
|
else if (customContentObjectString.Equals(m_kwaiObj))
|
|
{
|
|
return PlatformType.Kwai;
|
|
}
|
|
else
|
|
{
|
|
return PlatformType.NULL;
|
|
}
|
|
}
|
|
#else
|
|
return PlatformType.NULL;
|
|
#endif
|
|
}
|
|
|
|
public static AdsType GetAdsType(string toponRewardAdUnitId, string topinInterstitialAdUnitId, double rewardPrice, double interstitialPrice, double fullNativePrice)
|
|
{
|
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
|
using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
|
|
{
|
|
AndroidJavaObject activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
|
|
AndroidJavaObject toponRewardCustomContentInfo = new AndroidJavaObject("com.thinkup.core.api.TUCustomContentInfo", toponRewardAdUnitId, m_toponRewardObj);
|
|
AndroidJavaObject toponInterstitialCustomContentInfo = new AndroidJavaObject("com.thinkup.core.api.TUCustomContentInfo", topinInterstitialAdUnitId, m_toponInterstitialObj);
|
|
AndroidJavaObject rewardCustomContentInfo = new AndroidJavaObject("com.thinkup.core.api.TUCustomContentInfo", rewardPrice * 1000, m_rewardObj);
|
|
AndroidJavaObject interstitialCustomContentInfo = new AndroidJavaObject("com.thinkup.core.api.TUCustomContentInfo", interstitialPrice * 1000, m_interstitialObj);
|
|
AndroidJavaObject fullNativeCustomContentInfo = new AndroidJavaObject("com.thinkup.core.api.TUCustomContentInfo", fullNativePrice * 1000, m_fullNativeObj);
|
|
|
|
AndroidJavaObject atCustomContentInfoList = new AndroidJavaObject("java.util.ArrayList");
|
|
atCustomContentInfoList.Call<bool>("add", toponRewardCustomContentInfo);
|
|
atCustomContentInfoList.Call<bool>("add", toponInterstitialCustomContentInfo);
|
|
atCustomContentInfoList.Call<bool>("add", rewardCustomContentInfo);
|
|
atCustomContentInfoList.Call<bool>("add", interstitialCustomContentInfo);
|
|
atCustomContentInfoList.Call<bool>("add", fullNativeCustomContentInfo);
|
|
AndroidJavaClass sdkGlobalSetting = new AndroidJavaClass("com.thinkup.core.api.TUSDKGlobalSetting");
|
|
AndroidJavaObject maxPriceCustomContentInfo = sdkGlobalSetting.CallStatic<AndroidJavaObject>("customContentReviewResult", atCustomContentInfoList);
|
|
|
|
string customContentString = maxPriceCustomContentInfo.Get<string>("customContentString");
|
|
double customContentDouble = maxPriceCustomContentInfo.Get<double>("customContentDouble");
|
|
AndroidJavaObject customContentObject = maxPriceCustomContentInfo.Get<AndroidJavaObject>("customContentObject");
|
|
|
|
string customContentObjectString = customContentObject != null ? customContentObject.Call<string>("toString") : "null";
|
|
LoggerUtils.Debug("[AdsBidResult] rewardPrice: " + rewardPrice * 1000 + " interstitialPrice: " + interstitialPrice * 1000 + " fullNativePrice: " + fullNativePrice * 1000 + " toponRewardAdUnitId: " +toponRewardAdUnitId + " topinInterstitialAdUnitId: " + topinInterstitialAdUnitId);
|
|
LoggerUtils.Debug("[AdsBidResult] final maxPriceCustomContentInfo: " + customContentString + " double: " + customContentDouble + " object:" + customContentObjectString);
|
|
if (customContentObjectString.Equals(m_toponRewardObj))
|
|
{
|
|
return AdsType.Rewarded;
|
|
}
|
|
else if (customContentObjectString.Equals(m_toponInterstitialObj))
|
|
{
|
|
return AdsType.Interstitial;
|
|
}
|
|
else if (customContentObjectString.Equals(m_rewardObj))
|
|
{
|
|
return AdsType.Rewarded;
|
|
}
|
|
else if (customContentObjectString.Equals(m_interstitialObj))
|
|
{
|
|
return AdsType.Interstitial;
|
|
}
|
|
else if (customContentObjectString.Equals(m_fullNativeObj))
|
|
{
|
|
return AdsType.Native;
|
|
}
|
|
else
|
|
{
|
|
return AdsType.None;
|
|
}
|
|
}
|
|
#else
|
|
return AdsType.Rewarded;
|
|
#endif
|
|
|
|
}
|
|
}
|
|
} |