AASDKDemoScript.cs
2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using System;
using UnityEngine;
using AntiAddictionSDK.Api;
using AntiAddictionSDK.Common;
using AntiAddictionSDK;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class AASDKDemoScript: MonoBehaviour
{
AntiAddictionStytemSDK antiAddictionSDK;
public Text statusText;
public InputField inputField;
// Start is called before the first frame update
void Start()
{
antiAddictionSDK = new AntiAddictionStytemSDK();
antiAddictionSDK.ZAASDKCompleted += HandleZAASDKCompleted;
antiAddictionSDK.ZAASDKCheckPayCompleted += HandleZAASDKCheckPayCompleted;
}
// 获取用户实名认证状态
// 0: 未实名认证
// 1:已实名认证
public void IsAuthenticated()
{
if (antiAddictionSDK != null)
{
print("ZAASDK -- IsAuthenticated:" + antiAddictionSDK.IsAuthenticated());
}
}
// 获取当前用户年龄段
// 0 未认证
// 1 成年人
// 2 未成年人
public void GetUserAgeGroup()
{
if (antiAddictionSDK != null)
{
print("ZAASDK -- GetUserAgeGroup:" + antiAddictionSDK.AgeGroupOfCurrentUser());
}
}
// 获取当前用户剩余可玩时长
// 如果为-1,表示当前用户为成年人账号,将不受防沉迷限制
// 如果为大于0的数,返回的为当前用户的剩余可玩时长,单位秒
public void LeftTimeOfCurrentUser()
{
if (antiAddictionSDK != null)
{
print("ZAASDK -- LeftTimeOfCurrentUser:" + antiAddictionSDK.LeftTimeOfCurrentUser());
}
}
public void checkPayWithAmount()
{
int amountValue = int.Parse(inputField.text);
print("ZAASDK -- checkPayWithAmount:" + amountValue);
if (antiAddictionSDK != null)
{
antiAddictionSDK.checkPayWithAmount(amountValue);
}
}
public void recordPayWithAmount()
{
int amountValue = int.Parse(inputField.text);
print("ZAASDK -- recordPayWithAmount:" + amountValue);
if (antiAddictionSDK != null)
{
antiAddictionSDK.recordPayWithAmount(amountValue);
}
}
public void HandleZAASDKCompleted(object sender, EventArgs args)
{
print("ZAASDK -- HandleZAASDKCompleted");
}
public void HandleZAASDKCheckPayCompleted(object sender, EventArgs args)
{
print("ZAASDK -- HandleZAASDKCheckPayCompleted");
}
}