311 lines
9.3 KiB
C#
311 lines
9.3 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.UI;
|
|||
|
|
|
|||
|
|
namespace Touka
|
|||
|
|
{
|
|||
|
|
public class ToukaSDKDemo : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
|
|||
|
|
public Image nativeImage;
|
|||
|
|
|
|||
|
|
// Start is called before the first frame update
|
|||
|
|
void Start()
|
|||
|
|
{
|
|||
|
|
InitSDK();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region Init
|
|||
|
|
|
|||
|
|
public void OnShowNativeAd()
|
|||
|
|
{
|
|||
|
|
TKGSDKManager.Instance.ShowNative(nativeImage.rectTransform);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_Init()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_Init click, InitSDK auto Callfirst");
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void InitSDK()
|
|||
|
|
{
|
|||
|
|
OnButton_UserSource();
|
|||
|
|
OnButton_SetLogEnable();
|
|||
|
|
|
|||
|
|
TKGSDKManager.Instance.InitSDK(initCallback);
|
|||
|
|
TKGSDKManager.Instance.SetLogEnable(true);
|
|||
|
|
TKGSDKManager.Instance.SetRewardClickListener(ClickRewardCallback);
|
|||
|
|
TKGSDKManager.Instance.RegistAPNS();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ClickRewardCallback()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] click reward callback");
|
|||
|
|
}
|
|||
|
|
private void initCallback()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] init callback");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_SetLogEnable()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] SetLogEnable btn click");
|
|||
|
|
//TKGSDKManager.Instance.SetLogEnable(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Ads
|
|||
|
|
|
|||
|
|
public void OnButton_ShowInterstitialAd()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_ShowInterstitialAd click");
|
|||
|
|
//TKGSDKManager.Instance.ShowInterstitialAd(TKGIVAdPositionName.IV_Retry, IVCallback);
|
|||
|
|
DateTime now;
|
|||
|
|
DateTime delay;
|
|||
|
|
now = DateTime.Now;
|
|||
|
|
TKGSDKManager.Instance.RegistNotification("yangwu","hello world", now.AddDays(1).ToString("yyyy-MM-dd HH:mm:ss"),1,"Title","SubTitle");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
private void IV2Callback()
|
|||
|
|
{
|
|||
|
|
Debug.Log("unity [ToukaSDKDemo] IVCallback");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void IVCallback()
|
|||
|
|
{
|
|||
|
|
Debug.Log("unity [ToukaSDKDemo] IVCallback 2" );
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_ShowRewardAd()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_ShowRewardAd click");
|
|||
|
|
TKGSDKManager.Instance.ShowRewardAd(TKGRVPositionName.RV_GetDoubleCoin, RewardResult, RvShowFailed);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Reward result
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="pSucceed"> true:reward succ, false: reward failed </param>
|
|||
|
|
private void RewardResult(bool pSucceed)
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] Reward result:" + pSucceed);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Callback of reward ad show fail
|
|||
|
|
/// </summary>
|
|||
|
|
private void RvShowFailed()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] Reward ads show failed");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_IsReadyIV()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_IsReadyIV click");
|
|||
|
|
bool isReadyIV = TKGSDKManager.Instance.IsReadyInterstitialAd();
|
|||
|
|
Debug.Log("[ToukaSDKDemo] isReadyIV : " + isReadyIV);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_IsReadyRV()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_IsReadyRV click");
|
|||
|
|
bool isReadyRV = TKGSDKManager.Instance.IsReadyRewardAd();
|
|||
|
|
Debug.Log("[ToukaSDKDemo] isReadyRV : " + isReadyRV);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_ShowBanner()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_ShowBanner click");
|
|||
|
|
TKGSDKManager.Instance.ShowBanner(TKGBannerAlign.BannerCenterBottomAlign);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_HideBanner()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_HideBanner click");
|
|||
|
|
TKGSDKManager.Instance.HideBanner();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Event Tracking
|
|||
|
|
|
|||
|
|
public void OnButton_LevelStart()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_LevelStart click");
|
|||
|
|
TKGSDKManager.Instance.LevelStart(1);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_LevelSucc()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_LevelSucc click");
|
|||
|
|
TKGSDKManager.Instance.LevelEnd(1, StageResult.StageSucc);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_LevelFailed()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_LevelFailed click");
|
|||
|
|
TKGSDKManager.Instance.LevelEnd(2, StageResult.StageFail);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_LevelRetry()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_LevelRetry click");
|
|||
|
|
TKGSDKManager.Instance.LevelEnd(3, StageResult.StageRetry);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_LevelBack()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_LevelBack click");
|
|||
|
|
TKGSDKManager.Instance.LevelEnd("S_1", StageResult.StageBack);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_LogEventClick()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_LogEventClick click");
|
|||
|
|
TKGSDKManager.Instance.LogEvent("logEvent01");
|
|||
|
|
TKGSDKManager.Instance.LogEvent("logEvent02", "key02", "value02");
|
|||
|
|
TKGSDKManager.Instance.LogEvent("logEvent03", "key03-1", "value03-1", "key03-2", "value03-2");
|
|||
|
|
TKGSDKManager.Instance.LogEvent("logEvent04", new Dictionary<string, string> { { "DicKey04", "DicKey04" } });
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Get Remote Config
|
|||
|
|
|
|||
|
|
public void OnButton_GetConfigInt()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_GetConfigInt click");
|
|||
|
|
int onlineIntValue = TKGSDKManager.Instance.GetConfigInt(TKGParamKey.RemoveAdsShowCount);
|
|||
|
|
Debug.Log("online int value : " + onlineIntValue);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_GetConfigStr()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_GetConfigStr click");
|
|||
|
|
string onlineStrValue = TKGSDKManager.Instance.GetConfigStr(TKGParamKey.LevelList);
|
|||
|
|
Debug.Log("online string value : " + onlineStrValue);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_GetConfigBool()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_GetConfigBool click");
|
|||
|
|
bool onlineBoolValue = TKGSDKManager.Instance.GetConfigBool(TKGParamKey.HasBlock);
|
|||
|
|
Debug.Log("online bool value : " + onlineBoolValue);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Privacy Compliance
|
|||
|
|
|
|||
|
|
public void OnButton_OpenPrivacyUrl()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_OpenPrivacyUrl click");
|
|||
|
|
TKGSDKManager.Instance.OpenPolicyPop();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_OpenUserTermBtn()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_OpenUserTermBtn click");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region Others
|
|||
|
|
|
|||
|
|
public void OnButton_OpenMoreGame()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_OpenMoreGame click");
|
|||
|
|
TKGSDKManager.Instance.OpenMoreGame();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_ReviewBtn()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_ReviewBtn click");
|
|||
|
|
TKGSDKManager.Instance.Review();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
public void OnButton_SetGameFocusListener()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_SetGameFocusListener click");
|
|||
|
|
TKGSDKManager.Instance.SetGameFocusListener((_flg) => {
|
|||
|
|
if (_flg)
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_SetGameFocusListener false flg");
|
|||
|
|
PauseGame();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OnButton_SetGameFocusListener true flg");
|
|||
|
|
ResumeGame();
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void PauseGame()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] pause game callback");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void ResumeGame()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] resume game callback");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_OpenLocalPush()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] OpenLocalPush click");
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
* Assets/TKGSDK/Config/Scripts/StaticOtherConfig.cs
|
|||
|
|
1. set LocalNotitcifaction_Switch = true;
|
|||
|
|
2. set pushContent; // copy from product requirements
|
|||
|
|
MorrowMsgCN = "";
|
|||
|
|
Day357MsgCN = "";
|
|||
|
|
Day468MsgCN = "";
|
|||
|
|
*/
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_UserSource()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] Set UserSource Click, call before init");
|
|||
|
|
|
|||
|
|
TKGSDKManager.Instance.SetUserSourceListener((_isOrigin, _source) =>
|
|||
|
|
{
|
|||
|
|
Debug.Log("usersource"+_isOrigin+_source);
|
|||
|
|
if (_isOrigin)
|
|||
|
|
{
|
|||
|
|
Debug.Log("is origin user");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
Debug.Log("is not origin user");
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_CommonCallback()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] Set commonCallback Click");
|
|||
|
|
TKGSDKManager.Instance.SetTKGCommonCallback((code, msg) => {
|
|||
|
|
Debug.Log("common callback, code : " + code + " , msg : " + msg);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnButton_GetChannel()
|
|||
|
|
{
|
|||
|
|
Debug.Log("[ToukaSDKDemo] getChannel click");
|
|||
|
|
Debug.Log("channel : " + TKGSDKManager.Instance.GetChannel());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|