447 lines
13 KiB
C#
447 lines
13 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
namespace Touka
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// TKG Native SDK interface call
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract class TKGNativeInterface
|
|||
|
|
{
|
|||
|
|
private static TKGNativeInterface _instance;
|
|||
|
|
|
|||
|
|
private string UnitySDKVersion = "2.2.2";
|
|||
|
|
|
|||
|
|
public static TKGNativeInterface Instance
|
|||
|
|
{
|
|||
|
|
get
|
|||
|
|
{
|
|||
|
|
if (_instance == null)
|
|||
|
|
{
|
|||
|
|
#if UNITY_EDITOR || UNITY_STANDLONE
|
|||
|
|
_instance = new TKGNativeInterfaceWebgl();
|
|||
|
|
#elif UNITY_ANDROID
|
|||
|
|
_instance = new TKGNativeInterfaceAndroid();
|
|||
|
|
#elif UNITY_IOS
|
|||
|
|
_instance = new TKGNativeInterfaceIOS();
|
|||
|
|
#elif UNITY_WEBGL
|
|||
|
|
_instance = new TKGNativeInterfaceWebgl();
|
|||
|
|
#endif
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return _instance;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// init
|
|||
|
|
/// </summary>
|
|||
|
|
public virtual void Init(Action _initCallback = null)
|
|||
|
|
{
|
|||
|
|
TKGSDKCallback.SetInitCallback(_initCallback);
|
|||
|
|
SetUnitySDKVersion(UnitySDKVersion);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Set game focus
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_gameFocusAction"></param>
|
|||
|
|
public virtual void SetGameFocusListener(Action<bool> _gameFocusAction)
|
|||
|
|
{
|
|||
|
|
TKGSDKCallback.SetGameFocusCallback(_gameFocusAction);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public virtual void SetRewardClickListener(Action _rewardClickAction)
|
|||
|
|
{
|
|||
|
|
TKGSDKCallback.SetRewardClickCallback(_rewardClickAction);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Get Channel
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public abstract string GetChannel();
|
|||
|
|
|
|||
|
|
#region Ads
|
|||
|
|
|
|||
|
|
public abstract void PurchasedRemoveAds();
|
|||
|
|
|
|||
|
|
public abstract void SetUnitySDKVersion(string sdkVersion);
|
|||
|
|
|
|||
|
|
|
|||
|
|
#region Ads Show
|
|||
|
|
|
|||
|
|
public abstract void RemoveNativeAd();
|
|||
|
|
|
|||
|
|
public abstract bool IsReadyNativeAd();
|
|||
|
|
|
|||
|
|
public abstract void ShowNativeAd(RectTransform pRect, Camera pCam = null, string pAdPos = "");
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Show banner Ad
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_bannerAlign">bannerAlign</param>
|
|||
|
|
public abstract void showBannerAd(TKGBannerAlign _pos);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Hide Banner Ad
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract void hideBannerAd();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Show Interstitial Ad
|
|||
|
|
///
|
|||
|
|
/// auto log event : iv_ad_show
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract void showInterstitialAd();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Show Interstitial Ad
|
|||
|
|
///
|
|||
|
|
/// auto log event : iv_ad_show & _adPos(eg.stage_end)
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_position"></param>
|
|||
|
|
public abstract void showInterstitialAd(string _adPos, IVADType _IvType = IVADType.IV1);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Show Reward Ad
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_adPos"></param>
|
|||
|
|
/// <param name="_itemCount"></param>
|
|||
|
|
public abstract void showRewardAd(string _adPos, int _itemCount = -1);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Show Reward Ad
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_adPos"></param>
|
|||
|
|
/// <param name="_itemCount"></param>
|
|||
|
|
/// <param name="_extraEvent"></param>
|
|||
|
|
public abstract void showRewardAd(string _adPos, int _itemCount, Dictionary<string, string> _extraEvent);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Show Video Ad
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_adPos"></param>
|
|||
|
|
/// <param name="_itemCount"></param>
|
|||
|
|
public abstract void showVideoAd(string _adPos, int _itemCount = -1);
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Ads isready
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// banner isReady
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public abstract bool isBannerAdReady();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Interstitial isReady
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public abstract bool isInterstitialAdReady();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Reward isReady
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public abstract bool isRewardAdReady();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// FullScreen isReady
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public abstract bool isVideoAdReady();
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Set Ads callback
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Set Banner Ad Callback
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_bannerCallback"></param>
|
|||
|
|
public abstract void SetBannerAdCallback(AndroidBannerADTKGAdCallback _bannerCallback);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Set Interstital Ad Callback
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_interCallback"></param>
|
|||
|
|
public abstract void setInterstitalAdCallback(AndroidInterADTKGAdCallback _interCallback);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Set reward Ad Callback
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_rewardCallback"></param>
|
|||
|
|
public abstract void SetRewardAdCallback(AndroidRewardADTKGAdCallback _rewardCallback);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Set video Ad Callback(full screen ad, reward ad with no reward callback)
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_videoCallback"></param>
|
|||
|
|
public abstract void setVideoAdCallback(AndroidInterADTKGAdCallback _videoCallback);
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region load ads
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// load interstitial ad
|
|||
|
|
/// (retry 3 times, per time interval 10s)
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract void loadInterstitialAD();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// load reward ad
|
|||
|
|
/// (retry 3 times, per time interval 10s)
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract void loadRewardAD();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// load video ad
|
|||
|
|
/// (retry 3 times, per time interval 10s)
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract void loadVideoAD();
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Log Event
|
|||
|
|
|
|||
|
|
#region Normal
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// onEvent
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_eventName"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public abstract void onEvent(string _eventName);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// onEvent
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_eventName"></param>
|
|||
|
|
/// <param name="_key01"></param>
|
|||
|
|
/// <param name="_value01"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public abstract void onEvent(string _eventName, string _key01, string _value01);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// onEvent
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_eventName"></param>
|
|||
|
|
/// <param name="key01"></param>
|
|||
|
|
/// <param name="_value01"></param>
|
|||
|
|
/// <param name="_key02"></param>
|
|||
|
|
/// <param name="_value02"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public abstract void onEvent(string _eventName, string _key01, string _value01, string _key02, string _value02);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// onEvent
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_eventName"></param>
|
|||
|
|
/// <param name="_keyValues"></param>
|
|||
|
|
public abstract void onEvent(string _eventName, Dictionary<string, string> _keyValues);
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Level Event
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Level Start
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_levelId"></param>
|
|||
|
|
public abstract void LevelStart(string _levelId);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Level end
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_levelId"></param>
|
|||
|
|
/// <param name="_stageResult"></param>
|
|||
|
|
public abstract void LevelEnd(string _levelId, StageResult _stageResult);
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Tracking Event
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Log Tracking Event
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_eventType"></param>
|
|||
|
|
public abstract void LogTrackingEvent(TrackingEventType _eventType);
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Online Config
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// get config - int
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_key"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public abstract int GetConfigInt(string _key, int _default);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// get config - string
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_key"></param>
|
|||
|
|
/// <param name="_defaultValue"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public abstract string GetConfigString(string _key, string _default);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// get config - bool
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_key"></param>
|
|||
|
|
/// <param name="_defaultValue"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
public abstract bool GetConfigBool(string _key, bool _default);
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Others (Common)
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// review
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract void Review();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// open Privacy url
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract void OpenPrivacyURL();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// open user term url
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract void OpenUserTermURL();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// open policy pop
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract void OpenPolicyPop();
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// More Games
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract void OpenMoreGame();
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Others (Uncommon)
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// shake(no repeat)
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_shakeTime"> shake time </param>
|
|||
|
|
public abstract void shake(int _shakeType, float _intensity = 1);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// shake(can repeat)
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_repeatTimes"> repeat times : -1 </param>
|
|||
|
|
/// <param name="_shakeTime"> wait time,shake time(100,1000,100,111)</param>
|
|||
|
|
//public abstract void shake(int _repeatTimes, params int[] _shakeTime);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// cancel shake
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract void cancelShake();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Show Tips
|
|||
|
|
/// Pop-up prompt (the one with black transparent background) unified style, Chinese, Japanese, Korean and English, support multi-language, multi-language text
|
|||
|
|
///
|
|||
|
|
/// game judges different languages by itself and passes different strings
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_titleStr"> title </param>
|
|||
|
|
/// <param name="_contentStr"> content </param>
|
|||
|
|
public abstract void dialogTips(string _titleStr, string _contentStr);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Open ULR by Browser
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_url"></param>
|
|||
|
|
public abstract void openUrlBrowser(string _url);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Open ULR By WEB POP
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_url"></param>
|
|||
|
|
public abstract void openWebUrl(string _url);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// show Toast
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_content"></param>
|
|||
|
|
public abstract void toast(string _content);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// push message
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract void pushMsg();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// set log enable
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_enable"></param>
|
|||
|
|
public abstract void SetLogEnable(bool _enable);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// share txt
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="_shareTxt"></param>
|
|||
|
|
public abstract void ShareTxt(string _shareTxt);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// regist APNS
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract void RegistAPNS();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// shake
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="notiId">notification identifier</param>
|
|||
|
|
/// <param name="body">The body of the notification.</param>
|
|||
|
|
/// <param name="fireDate">notify after the time interval. format: yyyy-MM-dd HH:mm:ss </param>
|
|||
|
|
/// <param name="badge">The application badge number.</param>
|
|||
|
|
/// <param name="title">The title of the notification.</param>
|
|||
|
|
/// <param name="subTitle">The subtitle of the notification.</param>
|
|||
|
|
public abstract void RegistNotification(string notiId, string body, string fireDate, int badge, string title, string subTitle);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// remove all notification
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract void RemoveAllNotifications();
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// remove notification by notification identifier
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="notiId">notification identifier</param>
|
|||
|
|
public abstract void RemoveNotification(string notiId);
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region other callback
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// set tkg common callback
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract void SetSDKCommonCallback(AndroidTKGCommonCalllback _commonCallback);
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// set user source callback
|
|||
|
|
/// </summary>
|
|||
|
|
public abstract void SetUserSourceCallback(AndroidTKGUserSourceCalllback _userSourceCallback);
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|