AntiAddictionStytemSDK.cs
2.2 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
using System;
using AntiAddictionSDK.Common;
using UnityEngine;
namespace AntiAddictionSDK.Api
{
public class AntiAddictionStytemSDK
{
static readonly object objLock = new object();
IAntiAddictionClient client;
// Creates AntiAddictionSDK instance.
public AntiAddictionStytemSDK()
{
client = AntiAddictionClientFactory.BuildAntiAddictionClient();
if (client != null) {
client.ZAASDKCompleted += (sender, args) =>
{
if (ZAASDKCompleted != null)
{
ZAASDKCompleted(this, args);
}
};
client.ZAASDKCheckPayCompleted += (sender, args) =>
{
if (ZAASDKCheckPayCompleted != null)
{
ZAASDKCheckPayCompleted(this, args);
}
};
}
}
// 防沉迷流程结束,可以进入游戏
public event EventHandler<EventArgs> ZAASDKCompleted;
public event EventHandler<EventArgs> ZAASDKCheckPayCompleted;
// 获取用户实名认证状态
// 0: 未实名认证
// 1:已实名认证
public int IsAuthenticated()
{
return client.IsAuthenticated();
}
// 获取当前用户年龄段
// 0 未认证
// 1 成年人
// 2 未成年人
public int AgeGroupOfCurrentUser()
{
return client.AgeGroupOfCurrentUser();
}
// 获取当前用户剩余可玩时长
// 如果为-1,表示当前用户为成年人账号,将不受防沉迷限制
// 如果为大于0的数,返回的为当前用户的剩余可玩时长,单位秒
public int LeftTimeOfCurrentUser()
{
return client.LeftTimeOfCurrentUser();
}
public void checkPayWithAmount(int amount)
{
client.checkPayWithAmount(amount);
}
public void recordPayWithAmount(int amount)
{
client.recordPayWithAmount(amount);
}
}
}