2023-09-12 09:23:21 +00:00
using System ;
2022-06-13 07:55:30 +00:00
using System.Collections ;
using System.Collections.Generic ;
2023-09-12 09:23:21 +00:00
using System.Linq ;
2022-06-13 07:55:30 +00:00
using UnityEngine ;
namespace Touka
{
/// <summary>
/// TKG Native SDK Default platform interface call
/// </summary>
public class TKGNativeInterfaceDefault : TKGNativeInterface
{
public override void Init ( Action _initCallback = null )
{
_initCallback ? . Invoke ( ) ;
}
2022-08-30 02:21:29 +00:00
public override void SetUnitySDKVersion ( string sdkVersion )
{
}
2022-06-13 07:55:30 +00:00
/// <summary>
/// Get Channel
/// </summary>
/// <returns></returns>
public override string GetChannel ( )
{
return "" ;
}
2022-08-30 02:21:29 +00:00
/// <summary>
/// Set Log Enable
/// </summary>
/// <param name="_enable"></param>
public override void SetLogEnable ( bool _enable )
{
}
2022-06-13 07:55:30 +00:00
#region Ads
2022-08-30 02:21:29 +00:00
public override void PurchasedRemoveAds ( )
{
}
2022-06-13 07:55:30 +00:00
#region Ads Show
/// <summary>
/// Show banner Ad
/// </summary>
2022-08-30 02:21:29 +00:00
/// <param name="_bannerAlign">bannerAlign</param>
public override void showBannerAd ( TKGBannerAlign _pos )
2022-06-13 07:55:30 +00:00
{
}
/// <summary>
/// Hide Banner Ad
/// </summary>
public override void hideBannerAd ( )
{
}
/// <summary>
/// Show Interstitial Ad
/// </summary>
public override void showInterstitialAd ( )
{
}
/// <summary>
/// Show Interstitial Ad
/// </summary>
public override void showInterstitialAd ( string _adPos , IVADType _IvType = IVADType . IV1 )
{
}
/// <summary>
/// Show Reward Ad
/// </summary>
public override 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 override void showRewardAd ( string _adPos , int _itemCount , Dictionary < string , string > _extraEvent )
{
}
/// <summary>
/// Show FullScreen Ad(is RV without reward callback)
/// </summary>
public override void showVideoAd ( string _adPos , int _itemCount = - 1 )
{
}
#endregion
#region Ads isready
/// <summary>
/// banner isReady
/// </summary>
/// <returns></returns>
public override bool isBannerAdReady ( )
{
return false ;
}
/// <summary>
/// Interstitial isReady
/// </summary>
/// <returns></returns>
public override bool isInterstitialAdReady ( )
{
return false ;
}
/// <summary>
/// Reward isReady
/// </summary>
/// <returns></returns>
public override bool isRewardAdReady ( )
{
return false ;
}
/// <summary>
/// FullScreen isReady
/// </summary>
/// <returns></returns>
public override bool isVideoAdReady ( )
{
return false ;
}
#endregion
#region Set callback
/// <summary>
/// Set Banner Ad Callback
/// </summary>
/// <param name="_bannerCallback"></param>
public override void SetBannerAdCallback ( AndroidBannerADTKGAdCallback _bannerCallback )
{
}
2022-08-30 02:21:29 +00:00
/// <summary>
/// Set reward video click Callback
/// </summary>
/// <param name="_rewardClickAction"></param>
public override void SetRewardClickListener ( Action _rewardClickAction )
{
}
/// <summary>
/// Set game focus Callback
/// </summary>
/// <param name=""></param>
public override void SetGameFocusListener ( Action < bool > _gameFocusAction )
{
}
2022-06-13 07:55:30 +00:00
/// <summary>
/// Set Interstital Ad Callback
/// </summary>
/// <param name="_interCallback"></param>
public override void setInterstitalAdCallback ( AndroidInterADTKGAdCallback _interCallback )
{
}
/// <summary>
/// Set reward Ad Callback
/// </summary>
/// <param name="_rewardCallback"></param>
public override void SetRewardAdCallback ( AndroidRewardADTKGAdCallback _rewardCallback )
{
}
/// <summary>
/// Set video Ad Callback(full screen ad, reward ad with no reward callback)
/// </summary>
/// <param name="_videoCallback"></param>
public override void setVideoAdCallback ( AndroidInterADTKGAdCallback _videoCallback )
{
}
#endregion
#region load ads
/// <summary>
/// load interstitial ad
/// (retry 3 times, per time interval 10s)
/// </summary>
public override void loadInterstitialAD ( )
{
}
/// <summary>
/// load reward ad
/// (retry 3 times, per time interval 10s)
/// </summary>
public override void loadRewardAD ( )
{
}
/// <summary>
/// load video ad
/// (retry 3 times, per time interval 10s)
/// </summary>
public override void loadVideoAD ( )
{
}
#endregion
#endregion
#region Log Event
/// <summary>
/// onEvent
/// </summary>
/// <param name="_eventName"></param>
/// <returns></returns>
public override void onEvent ( string _eventName )
{
}
/// <summary>
/// onEvent
/// </summary>
/// <param name="_eventName"></param>
/// <param name="_key01"></param>
/// <param name="_value01"></param>
/// <returns></returns>
public override 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 override void onEvent ( string _eventName , string _key01 , string _value01 , string _key02 , string _value02 )
{
}
/// <summary>
/// onEvent
/// </summary>
/// <param name="_eventName"></param>
/// <param name="_keyValues"></param>
public override void onEvent ( string _eventName , Dictionary < string , string > _keyValues )
{
}
#region Level Event
/// <summary>
/// Level Start
/// </summary>
/// <param name="_levelId"></param>
public override void LevelStart ( string _levelId )
{
}
/// <summary>
/// Level end
/// </summary>
/// <param name="_levelId"></param>
2022-08-30 02:21:29 +00:00
/// <param name="_stageResult"></param>
public override void LevelEnd ( string _levelId , StageResult _stageResult )
2022-06-13 07:55:30 +00:00
{
}
#endregion
#region Tracking Event
/// <summary>
/// Log Tracking Event
/// </summary>
/// <param name="_eventType"></param>
public override void LogTrackingEvent ( TrackingEventType _eventType )
{
}
#endregion
#endregion
#region Online Config
/// <summary>
/// get config - int
/// </summary>
/// <param name="_key"></param>
/// <returns></returns>
2022-08-30 02:21:29 +00:00
public override int GetConfigInt ( string _key , int _default )
2022-06-13 07:55:30 +00:00
{
2022-08-30 02:21:29 +00:00
return _default ;
2022-06-13 07:55:30 +00:00
}
/// <summary>
/// get config - string
/// </summary>
/// <param name="_key"></param>
/// <returns></returns>
2022-08-30 02:21:29 +00:00
public override string GetConfigString ( string _key , string _default )
2022-06-13 07:55:30 +00:00
{
2022-08-30 02:21:29 +00:00
return _default ;
2022-06-13 07:55:30 +00:00
}
/// <summary>
/// get config - bool
/// </summary>
/// <param name="_key"></param>
/// <returns></returns>
2022-08-30 02:21:29 +00:00
public override bool GetConfigBool ( string _key , bool _default )
2022-06-13 07:55:30 +00:00
{
2022-08-30 02:21:29 +00:00
return default ;
2022-06-13 07:55:30 +00:00
}
#endregion
#region Others ( Common )
/// <summary>
/// review
/// </summary>
public override void Review ( )
{
}
/// <summary>
/// open Privacy
/// </summary>
public override void OpenPrivacyURL ( )
{
}
/// <summary>
/// open agreement
/// </summary>
public override void OpenUserTermURL ( )
{
}
/// <summary>
/// open policy pop
/// </summary>
public override void OpenPolicyPop ( )
{
}
/// <summary>
/// More Games
/// </summary>
public override void OpenMoreGame ( )
{
}
#endregion
#region Others ( Uncommon )
/// <summary>
/// shake(no repeat)
/// </summary>
/// <param name="_shakeTime"> shake time </param>
public override void shake ( int _shakeType , float _intensity = 1 )
{
2023-09-12 09:23:21 +00:00
}
/// <summary>
/// show picture cross
/// </summary>
public override bool showPictureCross ( )
{
return false ;
}
2022-06-13 07:55:30 +00:00
2023-09-12 09:23:21 +00:00
/// <summary>
/// remove picture cross
/// </summary>
public override void removePictureCross ( )
{
}
/// <summary>
/// show more game icon
/// </summary>
public override bool showMoreGameIcon ( )
{
return false ;
}
/// <summary>
/// remove more game icon
/// </summary>
public override void removeMoreGameIcon ( )
{
2022-06-13 07:55:30 +00:00
}
/// <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 override void shake(int _repeatTimes, params int[] _shakeTime)
//{
//}
/// <summary>
/// cancel shake
/// </summary>
public override 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 override void dialogTips ( string _titleStr , string _contentStr )
{
}
/// <summary>
/// Open ULR by Browser
/// </summary>
/// <param name="_url"></param>
public override void openUrlBrowser ( string _url )
{
}
/// <summary>
/// Open ULR By WEB POP
/// </summary>
/// <param name="_url"></param>
public override void openWebUrl ( string _url )
{
}
/// <summary>
/// show Toast
/// </summary>
/// <param name="_content"></param>
public override void toast ( string _content )
{
}
/// <summary>
/// push message
/// </summary>
public override void pushMsg ( )
{
}
#endregion
2022-08-30 02:21:29 +00:00
#region common callback
public override void SetSDKCommonCallback ( AndroidTKGCommonCalllback _commonCallback )
{
}
2022-06-13 07:55:30 +00:00
2022-08-30 02:21:29 +00:00
public override void SetUserSourceCallback ( AndroidTKGUserSourceCalllback _userSourceCallback )
{
}
2022-08-30 05:43:52 +00:00
public override void SetUserSourceCallback ( AndroidTKGUserSourceCalllbackWithCampaignName _userSourceCallback )
{
2023-09-12 09:23:21 +00:00
}
2022-08-30 05:43:52 +00:00
2023-09-12 09:23:21 +00:00
/// <summary>
/// get a iap product list for sdk config file
/// </summary>
public override Dictionary < string , string > GetIAPProductList ( )
{
return new Dictionary < string , string > ( ) ;
2022-08-30 05:43:52 +00:00
}
2022-08-30 02:21:29 +00:00
public override void RemoveNativeAd ( )
{
}
2023-09-12 09:23:21 +00:00
/// <summary>
/// set segment type to sdk
/// </summary>
/// <param name="type">segment type</param>
public override void SetSegment ( SegmentType type )
{
}
public override bool IsDebugMode ( )
{
return false ;
}
/// <summary>
/// get user name and user id card
/// </summary>
public override string GetUserNameAndUserIDCard ( )
{
return "0_0" ;
}
2022-08-30 02:21:29 +00:00
public override bool IsReadyNativeAd ( )
{
return false ;
}
public override void ShowNativeAd ( RectTransform pRect , Camera pCam = null , string pAdPos = "" )
{
}
2022-08-30 05:43:52 +00:00
public override void ShareTxt ( string _shareTxt )
{
}
public override void RegistAPNS ( )
{
}
2023-09-12 09:23:21 +00:00
public override void RegistNotification ( string notiId , string body , string fireDate , int badge , string title ,
string subTitle )
2022-08-30 05:43:52 +00:00
{
}
public override void RemoveNotification ( string notiId )
{
}
public override void RemoveAllNotifications ( )
{
}
public override void SetShowSDKToast ( bool _useSDKToast )
{
2023-09-12 09:23:21 +00:00
}
public override void SetFunctionSwitchCalllback ( List < FunctionType > _functionKeys ,
AndroidFunctionSwitchCalllback _functionSwitchCalllback )
{
}
#endregion
#region 数 据 中 台
public override void LogPurchasePrice ( string price , string currency )
{
}
public override void LogRobuxCashOut ( )
{
}
public override void LogNoviceGuideFinish ( )
{
}
public override bool GuidGpComment ( )
{
return true ;
}
#endregion
#region 用 户 登 录
public override void Login ( LoginType loginType ,
Action < LoginStatus , LoginType , string , string , string , string , string , string > loginResultCallback = null )
{
Server . Instance . Login ( loginType , ( status , msg , loginInfo ) = >
{
PlayerPrefs . SetInt ( "last_login_type" , ( int ) loginType ) ;
var loginStatus = status = = 0 ? LoginStatus . LOGIN_STATUS_SUCC : LoginStatus . LOGIN_STATUS_FAILED ;
var loginTypeEnum = ( LoginType ) Enum . ToObject ( typeof ( LoginType ) , loginInfo . user_type ) ;
PlayerPrefs . SetString ( "user_id" , loginInfo . user_id ) ;
PlayerPrefs . SetString ( "token" , loginInfo . token ) ;
PlayerPrefs . SetInt ( "user_type" , loginInfo . user_type ) ;
loginResultCallback ? . Invoke ( loginStatus , loginTypeEnum , msg , loginInfo . user_id , loginInfo . token , "" , "" ,
"" ) ;
} ) ;
}
public override void Logout ( Action _logoutCallback = null )
{
PlayerPrefs . DeleteKey ( "last_login_type" ) ;
PlayerPrefs . DeleteKey ( "user_id" ) ;
PlayerPrefs . DeleteKey ( "user_type" ) ;
PlayerPrefs . DeleteKey ( "token" ) ;
_logoutCallback ? . Invoke ( ) ;
}
public override List < LoginType > AvailableLoginChannelList ( )
{
var loginChannels = PlayerPrefs . GetString ( "loginChannels" , "" + ( int ) LoginType . LOGIN_BY_GUESTER ) ;
return loginChannels . Split ( ',' )
. Select ( channel = > ( LoginType ) Enum . ToObject ( typeof ( LoginType ) , int . Parse ( channel ) ) ) . ToList ( ) ;
}
public override void DeleteAccount ( Action < DeleteStatus , string > deleteAccountCallback = null )
{
Server . Instance . DeleteAccount ( PlayerPrefs . GetString ( "user_id" ) , ( code , msg ) = >
{
// 退出账号
Logout ( ) ;
deleteAccountCallback ? . Invoke (
code = = 0 ? DeleteStatus . DELETE_ACCOUNT_SUCC : DeleteStatus . DELETE_ACCOUNT_FAILED , msg ) ;
} ) ;
}
public override void BindAccount ( LoginType type , BindType isForce , string userId ,
Action < BindAccountStatus , LoginType , string , string , string , string , string , string , string [ ] >
bindAccountCallback )
{
var thirdUserId = "" ;
switch ( type )
{
case LoginType . LOGIN_BY_GOOGLE :
thirdUserId = PlayerPrefs . GetString ( "google_user_id" ) ;
break ;
case LoginType . LOGIN_BY_FACEBOOK :
thirdUserId = PlayerPrefs . GetString ( "facebook_user_id" ) ;
break ;
}
if ( isForce = = BindType . NO_FORCE )
{
userId = PlayerPrefs . GetString ( "user_id" ) ;
}
Server . Instance . Bind ( type , isForce , thirdUserId , userId , ( status , msg , data ) = >
{
if ( status ! = 0 )
{
bindAccountCallback . Invoke ( BindAccountStatus . BIND_CODE_FAILED , type , msg , data . user_id , data . token ,
"" , "" , "" , data . user_ids ) ;
return ;
}
if ( data . user_ids ! = null & & data . user_ids . Length = = 2 )
{
// (status, loginTYpe, msg, userId, token, email, displayName, photoUrl, userIdList)
bindAccountCallback . Invoke ( BindAccountStatus . BIND_CODE_SELECT , type , msg , data . user_id , data . token ,
"" , "" , "" , data . user_ids ) ;
}
else
{
PlayerPrefs . SetString ( "user_id" , data . user_id ) ;
PlayerPrefs . SetString ( "token" , data . token ) ;
PlayerPrefs . SetInt ( "user_type" , ( int ) type ) ;
bindAccountCallback . Invoke ( BindAccountStatus . BIND_CODE_SUCC , type , msg , data . user_id , data . token ,
"" , "" , "" , data . user_ids ) ;
}
} ) ;
}
public override void AutoLogin (
Action < LoginStatus , LoginType , string , string , string , string , string , string > loginResultCallback )
{
if ( ! IsCanAutoLogin ( ) )
{
loginResultCallback ? . Invoke ( LoginStatus . LOGIN_STATUS_NO_CACHE , LoginType . LOGIN_BY_AUTO ,
"not cache login" , "" , "" , "" , "" , "" ) ;
}
else
{
var lastLoginType = PlayerPrefs . GetInt ( "last_login_type" ) ;
Login ( ( LoginType ) Enum . ToObject ( typeof ( LoginType ) , lastLoginType ) , loginResultCallback ) ;
}
}
public override LoginType GetAccountType ( )
{
var userType = PlayerPrefs . GetInt ( "user_type" ) ;
return ( LoginType ) Enum . ToObject ( typeof ( LoginType ) , userType ) ;
}
2022-08-30 05:43:52 +00:00
2023-09-12 09:23:21 +00:00
public override bool IsCanAutoLogin ( )
{
return PlayerPrefs . HasKey ( "last_login_type" ) ;
2022-08-30 05:43:52 +00:00
}
2022-08-30 02:21:29 +00:00
#endregion
2022-06-13 07:55:30 +00:00
2023-09-12 09:23:21 +00:00
#region IAP Event
/// <summary>
/// Log IAP button show
/// </summary>
public override void LogIAPBtnShow ( string _productName , string _productID )
{
}
/// <summary>
/// Log IAP button Click
/// </summary>
public override void LogIAPBtnClick ( string _productName , string _productID )
{
}
/// <summary>
/// Log IAP First payment successful
/// </summary>
public override void LogIAPFirstPurchase ( string _iap , string _id , string _paymentChannelOrderid , string _currency , string _price )
{
}
/// <summary>
/// Log IAP payment successful
/// </summary>
public override void LogIAPSuccess ( string _iap , string _id , string _gameOrderid , string _paymentChannelOrderid ,
string _productToken , string _paymentMethod , string _currency , string _price )
{
}
public override void SaveCloudArchiving ( string content , Action < int , string > callback )
{
var userId = PlayerPrefs . GetString ( "user_id" ) ;
var token = PlayerPrefs . GetString ( "token" ) ;
Server . Instance . SaveCloudArchiving ( userId , token , content , callback ) ;
}
public override void DetailCloudArchiving ( Action < int , string > callback )
{
var userId = PlayerPrefs . GetString ( "user_id" ) ;
var token = PlayerPrefs . GetString ( "token" ) ;
Server . Instance . DetailCloudArchiving ( userId , token ,
( code , msg , content ) = > { callback . Invoke ( code , code = = 0 ? content : msg ) ; } ) ;
}
#endregion
#region
/// <summary>
/// Set userid and third account
/// </summary>
/// <param name="_userID"> userID (Unique user id)</param>
/// <param name="_thirdAccount">third account </param>
/// <param name="_thirdAccountType"> third account type </param>
public override void SetUserIDAndThirdAccount ( string _userID , string _thirdAccount , ThirdAccountType _thirdAccountType )
{
Debug . Log ( "【TKGNativeInterfaceDefault】 SetUserIDAndThirdAccount _userID : " + _userID + " , _thirdAccount : " + _thirdAccount + " , _thirdAccountType : " + _thirdAccountType ) ;
}
#endregion
#region client iap pay result
/// <summary>
/// Client IAP Success
/// </summary>
public override void ClientIAPSuccess ( string _productName , string _productID , string _purchaseOrderID , string _purchaseToken , string _currency , string _price , string _gameExtra )
{
// todo 直接回调支付成功
TKGSDKCallback . mSecondPurchaseCallback ? . Invoke ( _purchaseOrderID , _productName , _productID , true , _gameExtra ) ;
}
/// <summary>
/// Client IAP Failed
/// </summary>
public override void ClientIAPFailed ( string _productName , string _productID , string _purchaseOrderID , string _purchaseToken , string _currency , string _price , string _gameExtra , IAPClientFailReasonType _failType )
{
// todo 直接回调支付失败
TKGSDKCallback . mSecondPurchaseCallback ? . Invoke ( _purchaseOrderID , _productName , _productID , false , _gameExtra ) ;
}
#endregion
2022-06-13 07:55:30 +00:00
}
}