com.taptap.sdk.core 4.9.5-beta.1 → 4.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Mobile/Editor/NativeDependencies.xml +2 -2
- package/Runtime/Internal/Platform/ITapCorePlatform.cs +6 -0
- package/Runtime/Public/TapTapPCState.cs +12 -0
- package/Runtime/Public/TapTapPCState.cs.meta +11 -0
- package/Runtime/Public/TapTapSDK.cs +20 -0
- package/Standalone/Plugins/x86_64/taptap_api.dll +0 -0
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogStandalone.cs +4 -1
- package/Standalone/Runtime/Internal/TapClientBridge.cs +41 -213
- package/Standalone/Runtime/Public/TapClientStandalone.cs +173 -156
- package/Standalone/Runtime/Public/TapCoreStandalone.cs +12 -0
- package/package.json +1 -1
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
<repositories>
|
|
5
5
|
<repository>https://repo.maven.apache.org/maven2</repository>
|
|
6
6
|
</repositories>
|
|
7
|
-
<androidPackage spec="com.taptap.sdk:tap-core-unity:4.9.
|
|
7
|
+
<androidPackage spec="com.taptap.sdk:tap-core-unity:4.9.5" />
|
|
8
8
|
</androidPackages>
|
|
9
9
|
<iosPods>
|
|
10
10
|
<sources>
|
|
11
11
|
<source>https://github.com/CocoaPods/Specs.git</source>
|
|
12
12
|
</sources>
|
|
13
|
-
<iosPod addToAllTargets="false" bitcodeEnabled="false" name="TapTapSDK/Core" version="4.9.
|
|
13
|
+
<iosPod addToAllTargets="false" bitcodeEnabled="false" name="TapTapSDK/Core" version="4.9.5" />
|
|
14
14
|
</iosPods>
|
|
15
15
|
</dependencies>
|
|
@@ -20,5 +20,11 @@ namespace TapSDK.Core.Internal
|
|
|
20
20
|
string action,
|
|
21
21
|
Dictionary<string, string> properties
|
|
22
22
|
);
|
|
23
|
+
|
|
24
|
+
#if UNITY_STANDALONE_WIN
|
|
25
|
+
void RegisterTapTapPCStateChangeListener(Action<int> action);
|
|
26
|
+
|
|
27
|
+
void UnRegisterTapTapPCStateChangeListener(Action<int> action);
|
|
28
|
+
#endif
|
|
23
29
|
}
|
|
24
30
|
}
|
|
@@ -162,6 +162,26 @@ namespace TapSDK.Core {
|
|
|
162
162
|
return platformWrapper?.IsLaunchedFromTapTapPC();
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
#if UNITY_STANDALONE_WIN
|
|
166
|
+
/// <summary>
|
|
167
|
+
/// 注册 TapTap PC 客户端运行状态监听
|
|
168
|
+
/// </summary>
|
|
169
|
+
/// <param name="action">监听回调</param>
|
|
170
|
+
public static void RegisterTapTapPCStateChangeListener(Action<int> action)
|
|
171
|
+
{
|
|
172
|
+
platformWrapper?.RegisterTapTapPCStateChangeListener(action);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/// <summary>
|
|
176
|
+
/// 移除 TapTap PC 客户端运行状态监听
|
|
177
|
+
/// </summary>
|
|
178
|
+
/// <param name="action">监听回调</param>
|
|
179
|
+
public static void UnRegisterTapTapPCStateChangeListener(Action<int> action)
|
|
180
|
+
{
|
|
181
|
+
platformWrapper?.UnRegisterTapTapPCStateChangeListener(action);
|
|
182
|
+
}
|
|
183
|
+
#endif
|
|
184
|
+
|
|
165
185
|
private static Type[] GetInitTypeList(){
|
|
166
186
|
Type interfaceType = typeof(IInitTask);
|
|
167
187
|
Type[] initTaskTypes = AppDomain.CurrentDomain.GetAssemblies()
|
|
Binary file
|
|
@@ -36,6 +36,8 @@ namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
|
36
36
|
#if UNITY_STANDALONE
|
|
37
37
|
InitGeneralParameter();
|
|
38
38
|
InitOpenlogStartParameter();
|
|
39
|
+
// c++ 初始化前设置日志等级,避免初始化日志直接输出
|
|
40
|
+
TdkSetLogLevel(1, TapCoreStandalone.coreOptions.enableLog ? 1 : 0);
|
|
39
41
|
string openlogStartStr = JsonConvert.SerializeObject(openlogStartParameter);
|
|
40
42
|
int result = TdkOnAppStarted(openlogStartStr, commonVariablesGetter, freeString);
|
|
41
43
|
BindWindowChange();
|
|
@@ -151,7 +153,8 @@ namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
|
151
153
|
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_REGION] =
|
|
152
154
|
TapCoreStandalone.coreOptions.region;
|
|
153
155
|
}
|
|
154
|
-
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_LOG_TO_CONSOLE] =
|
|
156
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_LOG_TO_CONSOLE] =
|
|
157
|
+
TapCoreStandalone.coreOptions.enableLog ? 1 : 0;
|
|
155
158
|
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_LOG_LEVEL] = 1;
|
|
156
159
|
string openLogDirPath = Path.Combine(Application.persistentDataPath, "OpenlogData");
|
|
157
160
|
if (
|
|
@@ -1,25 +1,21 @@
|
|
|
1
1
|
using System;
|
|
2
|
-
using System.Collections.Generic;
|
|
3
|
-
using System.IO;
|
|
4
|
-
using System.Threading.Tasks;
|
|
5
|
-
using UnityEngine;
|
|
6
2
|
using System.Runtime.InteropServices;
|
|
7
3
|
using System.Text;
|
|
8
4
|
using TapSDK.Core.Internal.Log;
|
|
9
5
|
|
|
10
|
-
|
|
11
|
-
|
|
12
6
|
namespace TapSDK.Core.Standalone.Internal
|
|
13
7
|
{
|
|
14
|
-
|
|
15
8
|
internal enum TapSDKInitResult
|
|
16
9
|
{
|
|
17
10
|
// 初始化成功
|
|
18
11
|
OK = 0,
|
|
12
|
+
|
|
19
13
|
// 其他错误
|
|
20
14
|
FailedGeneric = 1,
|
|
15
|
+
|
|
21
16
|
// 未找到 TapTap,用户可能未安装,请引导用户下载安装 TapTap
|
|
22
17
|
NoPlatform = 2,
|
|
18
|
+
|
|
23
19
|
// 已安装 TapTap,游戏未通过 TapTap 启动
|
|
24
20
|
NotLaunchedByPlatform = 3,
|
|
25
21
|
|
|
@@ -27,65 +23,54 @@ namespace TapSDK.Core.Standalone.Internal
|
|
|
27
23
|
PlatformVersionMismatch = 4,
|
|
28
24
|
|
|
29
25
|
// SDK 本地执行时未知错误
|
|
30
|
-
Unknown = -1
|
|
31
|
-
|
|
26
|
+
Unknown = -1,
|
|
32
27
|
};
|
|
33
28
|
|
|
34
29
|
internal enum TapEventID
|
|
35
30
|
{
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
AuthorizeFinished = 2002,
|
|
39
|
-
|
|
40
|
-
// [4001, 6000), reserved for TapTap ownership events
|
|
41
|
-
GamePlayableStatusChanged = 4001,
|
|
42
|
-
DLCPlayableStatusChanged = 4002,
|
|
43
|
-
};
|
|
31
|
+
SystemStateChanged = 1, // TapTap 客户端运行状态事件监听
|
|
32
|
+
}
|
|
44
33
|
|
|
45
34
|
// 系统事件类型
|
|
46
35
|
internal enum SystemState
|
|
47
36
|
{
|
|
48
|
-
|
|
49
|
-
|
|
37
|
+
Unknown = 0, // 未知
|
|
38
|
+
Online = 1, // 在线
|
|
39
|
+
Offline = 2, // 离线
|
|
40
|
+
Shutdown = 3, // 退出
|
|
50
41
|
};
|
|
51
42
|
|
|
52
|
-
//
|
|
53
|
-
|
|
43
|
+
// 授权返回结果结构体
|
|
44
|
+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
|
45
|
+
internal struct SystemStateResponse
|
|
54
46
|
{
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
FAILED = 2, // 授权失败
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
// 完成授权后的返回结果
|
|
61
|
-
internal enum Result
|
|
62
|
-
{
|
|
63
|
-
kResult_OK = 0,
|
|
64
|
-
kResult_Failed = 1,
|
|
65
|
-
kResult_Canceled = 2,
|
|
66
|
-
};
|
|
67
|
-
|
|
47
|
+
public int state; // 运行状态
|
|
48
|
+
}
|
|
68
49
|
|
|
69
50
|
public class TapClientBridge
|
|
70
51
|
{
|
|
71
|
-
|
|
72
52
|
#if UNITY_STANDALONE_WIN
|
|
73
53
|
public const string DLL_NAME = "taptap_api";
|
|
74
54
|
#endif
|
|
75
55
|
|
|
76
56
|
#if UNITY_STANDALONE_WIN
|
|
77
57
|
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
78
|
-
internal static extern bool TapSDK_RestartAppIfNecessary(
|
|
58
|
+
internal static extern bool TapSDK_RestartAppIfNecessary(
|
|
59
|
+
[MarshalAs(UnmanagedType.LPStr)] string clientId
|
|
60
|
+
);
|
|
79
61
|
|
|
80
62
|
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
81
|
-
internal static extern int TapSDK_Init(
|
|
63
|
+
internal static extern int TapSDK_Init(
|
|
64
|
+
StringBuilder errMsg,
|
|
65
|
+
[MarshalAs(UnmanagedType.LPStr)] string pubKey
|
|
66
|
+
);
|
|
82
67
|
|
|
83
68
|
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
84
69
|
internal static extern void TapSDK_Shutdown();
|
|
85
70
|
|
|
86
71
|
// 定义与 C 兼容的委托
|
|
87
72
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
88
|
-
|
|
73
|
+
public delegate void CallbackDelegate(int id, IntPtr userData);
|
|
89
74
|
|
|
90
75
|
// 系统状态返回结果结构体
|
|
91
76
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
|
@@ -95,27 +80,13 @@ namespace TapSDK.Core.Standalone.Internal
|
|
|
95
80
|
}
|
|
96
81
|
|
|
97
82
|
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
98
|
-
|
|
83
|
+
public static extern void TapSDK_RegisterCallback(int callbackId, IntPtr callback);
|
|
99
84
|
|
|
100
85
|
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
101
86
|
internal static extern void TapSDK_RunCallbacks();
|
|
102
87
|
|
|
103
88
|
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
// 登录相关接口
|
|
108
|
-
|
|
109
|
-
// 授权返回结果结构体
|
|
110
|
-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
|
111
|
-
public struct AuthorizeFinishedResponse
|
|
112
|
-
{
|
|
113
|
-
public int is_cancel; // 是否取消
|
|
114
|
-
|
|
115
|
-
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 1024)]
|
|
116
|
-
public string callback_uri; // 256 字节的 C 端字符串
|
|
117
|
-
|
|
118
|
-
}
|
|
89
|
+
public static extern void TapSDK_UnregisterCallback(int callbackId, IntPtr callback);
|
|
119
90
|
|
|
120
91
|
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
121
92
|
internal static extern bool TapUser_GetOpenID(StringBuilder openId);
|
|
@@ -123,46 +94,6 @@ namespace TapSDK.Core.Standalone.Internal
|
|
|
123
94
|
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
124
95
|
internal static extern bool TapSDK_GetClientID(StringBuilder clientId);
|
|
125
96
|
|
|
126
|
-
|
|
127
|
-
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
128
|
-
internal static extern int TapUser_AsyncAuthorize_internal([MarshalAs(UnmanagedType.LPStr)] string scopeStrings, [MarshalAs(UnmanagedType.LPStr)] string responseType,
|
|
129
|
-
[MarshalAs(UnmanagedType.LPStr)] string redirectUri, [MarshalAs(UnmanagedType.LPStr)] string codeChallenge, [MarshalAs(UnmanagedType.LPStr)] string state,
|
|
130
|
-
[MarshalAs(UnmanagedType.LPStr)] string codeChallengeMethod, [MarshalAs(UnmanagedType.LPStr)] string versonCode, [MarshalAs(UnmanagedType.LPStr)] string sdkUa, [MarshalAs(UnmanagedType.LPStr)] string info);
|
|
131
|
-
|
|
132
|
-
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
133
|
-
internal static extern int TapUser_AsyncAuthorize([MarshalAs(UnmanagedType.LPStr)] string scopeStrings);
|
|
134
|
-
|
|
135
|
-
// DLC 接口
|
|
136
|
-
// 检查是否拥有当前游戏
|
|
137
|
-
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
138
|
-
internal static extern bool TapApps_IsOwned();
|
|
139
|
-
|
|
140
|
-
// 游戏本体可玩状态变更事件响应结构体
|
|
141
|
-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
|
142
|
-
public struct GamePlayableStatusChangedResponse
|
|
143
|
-
{
|
|
144
|
-
public byte is_playable; // 游戏本体是否可玩
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
// 显示指定 DLC 的商店页面
|
|
148
|
-
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
149
|
-
internal static extern bool TapDLC_ShowStore([MarshalAs(UnmanagedType.LPStr)] string dlcId);
|
|
150
|
-
|
|
151
|
-
// 查询用户是否拥有指定的 DLC
|
|
152
|
-
[DllImport(DLL_NAME, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
|
|
153
|
-
internal static extern bool TapDLC_IsOwned([MarshalAs(UnmanagedType.LPStr)] string dlcId);
|
|
154
|
-
|
|
155
|
-
// DLC 授权完成响应结果
|
|
156
|
-
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
|
|
157
|
-
public struct DLCPlayableStatusChangedResponse
|
|
158
|
-
{
|
|
159
|
-
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 32)]
|
|
160
|
-
public string dlc_id; // DLC ID
|
|
161
|
-
|
|
162
|
-
public byte is_playable; // 是否可玩,当用户购买 DLC (外置 DLC 为购买且下载完成后),此值返回 true。其他情况返回 false
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
97
|
// 初始化检查
|
|
167
98
|
internal static int CheckInitState(out string errMessage, string key)
|
|
168
99
|
{
|
|
@@ -173,113 +104,10 @@ namespace TapSDK.Core.Standalone.Internal
|
|
|
173
104
|
return result;
|
|
174
105
|
}
|
|
175
106
|
|
|
176
|
-
// 预防 GC 回收的静态变量
|
|
177
|
-
private static CallbackDelegate _dlcCallbackInstance;
|
|
178
|
-
|
|
179
|
-
private static CallbackDelegate _userCallbackInternalInstance;
|
|
180
|
-
|
|
181
|
-
private static CallbackDelegate _userCallbackInstance;
|
|
182
|
-
|
|
183
|
-
private static CallbackDelegate _licenseCallbackInstance;
|
|
184
|
-
internal static void RegisterCallback(TapEventID eventID, CallbackDelegate callback)
|
|
185
|
-
{
|
|
186
|
-
|
|
187
|
-
IntPtr funcPtr = Marshal.GetFunctionPointerForDelegate(callback);
|
|
188
|
-
switch (eventID)
|
|
189
|
-
{
|
|
190
|
-
case TapEventID.DLCPlayableStatusChanged:
|
|
191
|
-
if (_dlcCallbackInstance != null)
|
|
192
|
-
{
|
|
193
|
-
UnRegisterCallback(eventID, _dlcCallbackInstance);
|
|
194
|
-
}
|
|
195
|
-
_dlcCallbackInstance = callback;
|
|
196
|
-
break;
|
|
197
|
-
case TapEventID.GamePlayableStatusChanged:
|
|
198
|
-
if (_licenseCallbackInstance != null)
|
|
199
|
-
{
|
|
200
|
-
UnRegisterCallback(eventID, _licenseCallbackInstance);
|
|
201
|
-
}
|
|
202
|
-
_licenseCallbackInstance = callback;
|
|
203
|
-
break;
|
|
204
|
-
case TapEventID.AuthorizeFinished_internal:
|
|
205
|
-
if (_userCallbackInternalInstance != null)
|
|
206
|
-
{
|
|
207
|
-
UnRegisterCallback(eventID, _userCallbackInternalInstance);
|
|
208
|
-
}
|
|
209
|
-
_userCallbackInternalInstance = callback;
|
|
210
|
-
break;
|
|
211
|
-
case TapEventID.AuthorizeFinished:
|
|
212
|
-
if (_userCallbackInstance != null)
|
|
213
|
-
{
|
|
214
|
-
UnRegisterCallback(eventID, _userCallbackInstance);
|
|
215
|
-
}
|
|
216
|
-
_userCallbackInstance = callback;
|
|
217
|
-
break;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
TapSDK_RegisterCallback((int)eventID, funcPtr);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// 移除回调
|
|
224
|
-
internal static void UnRegisterCallback(TapEventID eventID, CallbackDelegate callback)
|
|
225
|
-
{
|
|
226
|
-
|
|
227
|
-
IntPtr funcPtr = Marshal.GetFunctionPointerForDelegate(callback);
|
|
228
|
-
switch (eventID)
|
|
229
|
-
{
|
|
230
|
-
case TapEventID.DLCPlayableStatusChanged:
|
|
231
|
-
_dlcCallbackInstance = null;
|
|
232
|
-
break;
|
|
233
|
-
case TapEventID.GamePlayableStatusChanged:
|
|
234
|
-
_licenseCallbackInstance = null;
|
|
235
|
-
break;
|
|
236
|
-
case TapEventID.AuthorizeFinished_internal:
|
|
237
|
-
_userCallbackInternalInstance = null;
|
|
238
|
-
break;
|
|
239
|
-
case TapEventID.AuthorizeFinished:
|
|
240
|
-
_userCallbackInstance = null;
|
|
241
|
-
break;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
TapSDK_UnregisterCallback((int)eventID, funcPtr);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
internal static AuthorizeResult LoginWithScopesInternal(string[] scopeStrings, string responseType, string redirectUri,
|
|
248
|
-
string codeChallenge, string state, string codeChallengeMethod, string versonCode, string sdkUa, string info)
|
|
249
|
-
{
|
|
250
|
-
try
|
|
251
|
-
{
|
|
252
|
-
TapLog.Log("login start ==== " + string.Join(",", scopeStrings));
|
|
253
|
-
int result = TapUser_AsyncAuthorize_internal(string.Join(",", scopeStrings), responseType, redirectUri,
|
|
254
|
-
codeChallenge, state, codeChallengeMethod, versonCode, sdkUa, info);
|
|
255
|
-
TapLog.Log("login end === " + result);
|
|
256
|
-
return (AuthorizeResult)result;
|
|
257
|
-
}
|
|
258
|
-
catch (Exception ex)
|
|
259
|
-
{
|
|
260
|
-
TapLog.Log("login crash = " + ex.StackTrace);
|
|
261
|
-
return AuthorizeResult.UNKNOWN;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
internal static AuthorizeResult LoginWithScopes(string[] scopeStrings)
|
|
266
|
-
{
|
|
267
|
-
try
|
|
268
|
-
{
|
|
269
|
-
int result = TapUser_AsyncAuthorize(string.Join(",", scopeStrings));
|
|
270
|
-
return (AuthorizeResult)result;
|
|
271
|
-
}
|
|
272
|
-
catch (Exception ex)
|
|
273
|
-
{
|
|
274
|
-
TapLog.Log("login crash = " + ex.Message);
|
|
275
|
-
return AuthorizeResult.UNKNOWN;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
|
|
279
107
|
internal static bool GetTapUserOpenId(out string openId)
|
|
280
108
|
{
|
|
281
109
|
StringBuilder openIdBuffer = new StringBuilder(256); // 分配一个足够大的缓冲区
|
|
282
|
-
bool success = TapUser_GetOpenID(openIdBuffer);
|
|
110
|
+
bool success = TapUser_GetOpenID(openIdBuffer); // 调用 C 函数
|
|
283
111
|
openId = openIdBuffer.ToString();
|
|
284
112
|
return success;
|
|
285
113
|
}
|
|
@@ -287,29 +115,29 @@ namespace TapSDK.Core.Standalone.Internal
|
|
|
287
115
|
internal static bool GetClientId(out string clientId)
|
|
288
116
|
{
|
|
289
117
|
StringBuilder clientIDBuffer = new StringBuilder(256); // 分配一个足够大的缓冲区
|
|
290
|
-
bool success = TapSDK_GetClientID(clientIDBuffer);
|
|
118
|
+
bool success = TapSDK_GetClientID(clientIDBuffer); // 调用 C 函数
|
|
291
119
|
clientId = clientIDBuffer.ToString();
|
|
292
120
|
return success;
|
|
293
121
|
}
|
|
294
|
-
|
|
295
|
-
internal static bool QueryDLC(string skuId)
|
|
296
|
-
{
|
|
297
|
-
return TapDLC_IsOwned(skuId);
|
|
298
|
-
}
|
|
299
122
|
|
|
300
|
-
|
|
123
|
+
private static CallbackDelegate _systemStateCallbackInstance;
|
|
124
|
+
internal static void RegisterSystemStateCallback(CallbackDelegate callback)
|
|
301
125
|
{
|
|
302
|
-
|
|
126
|
+
IntPtr funcPtr = Marshal.GetFunctionPointerForDelegate(callback);
|
|
127
|
+
if (_systemStateCallbackInstance != null)
|
|
128
|
+
{
|
|
129
|
+
UnRegisterSystemStateCallback(_systemStateCallbackInstance);
|
|
130
|
+
}
|
|
131
|
+
_systemStateCallbackInstance = callback;
|
|
132
|
+
TapSDK_RegisterCallback((int)TapEventID.SystemStateChanged, funcPtr);
|
|
303
133
|
}
|
|
304
134
|
|
|
305
|
-
internal static
|
|
135
|
+
internal static void UnRegisterSystemStateCallback(CallbackDelegate callback)
|
|
306
136
|
{
|
|
307
|
-
|
|
137
|
+
IntPtr funcPtr = Marshal.GetFunctionPointerForDelegate(callback);
|
|
138
|
+
TapSDK_UnregisterCallback((int)TapEventID.SystemStateChanged, funcPtr);
|
|
139
|
+
_systemStateCallbackInstance = null;
|
|
308
140
|
}
|
|
309
|
-
|
|
310
141
|
#endif
|
|
311
142
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
}
|
|
143
|
+
}
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
using UnityEngine;
|
|
2
|
-
using System.Threading.Tasks;
|
|
3
|
-
using TapSDK.Core.Internal.Utils;
|
|
4
|
-
using TapSDK.Core.Standalone.Internal;
|
|
5
|
-
using TapSDK.UI;
|
|
6
1
|
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
7
3
|
using System.Runtime.InteropServices;
|
|
8
|
-
using TapSDK.Core.Standalone.Internal.Openlog;
|
|
9
4
|
using System.Threading;
|
|
5
|
+
using System.Threading.Tasks;
|
|
10
6
|
using TapSDK.Core.Internal.Log;
|
|
7
|
+
using TapSDK.Core.Internal.Utils;
|
|
8
|
+
using TapSDK.Core.Standalone.Internal;
|
|
9
|
+
using TapSDK.Core.Standalone.Internal.Openlog;
|
|
10
|
+
using TapSDK.UI;
|
|
11
11
|
using UnityEditor;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
using UnityEngine;
|
|
14
13
|
|
|
15
14
|
namespace TapSDK.Core.Standalone
|
|
16
15
|
{
|
|
17
16
|
#if UNITY_STANDALONE_WIN
|
|
18
17
|
public class TapClientStandalone
|
|
19
18
|
{
|
|
20
|
-
|
|
21
19
|
// 是否是渠道服游戏包
|
|
22
20
|
private static bool isChannelPackage = false;
|
|
23
21
|
|
|
@@ -25,7 +23,6 @@ namespace TapSDK.Core.Standalone
|
|
|
25
23
|
private static int lastIsLaunchedFromTapTapPCResult = -1;
|
|
26
24
|
private static bool isRuningIsLaunchedFromTapTapPC = false;
|
|
27
25
|
|
|
28
|
-
|
|
29
26
|
// 当为渠道游戏包时,与启动器的初始化校验结果
|
|
30
27
|
private static TapInitResult tapInitResult;
|
|
31
28
|
|
|
@@ -37,14 +34,20 @@ namespace TapSDK.Core.Standalone
|
|
|
37
34
|
// 正在执行中
|
|
38
35
|
if (isRuningIsLaunchedFromTapTapPC)
|
|
39
36
|
{
|
|
40
|
-
UIManager.Instance.OpenToast(
|
|
37
|
+
UIManager.Instance.OpenToast(
|
|
38
|
+
"IsLaunchedFromTapTapPC 正在执行,请勿重复调用",
|
|
39
|
+
UIManager.GeneralToastLevel.Error
|
|
40
|
+
);
|
|
41
41
|
TapLog.Error("IsLaunchedFromTapTapPC 正在执行,请勿重复调用");
|
|
42
42
|
return false;
|
|
43
43
|
}
|
|
44
44
|
// 多次执行时返回上一次结果
|
|
45
45
|
if (lastIsLaunchedFromTapTapPCResult != -1)
|
|
46
46
|
{
|
|
47
|
-
TapLog.Log(
|
|
47
|
+
TapLog.Log(
|
|
48
|
+
"IsLaunchedFromTapTapPC duplicate invoke return "
|
|
49
|
+
+ lastIsLaunchedFromTapTapPCResult
|
|
50
|
+
);
|
|
48
51
|
return lastIsLaunchedFromTapTapPCResult > 0;
|
|
49
52
|
}
|
|
50
53
|
|
|
@@ -52,7 +55,10 @@ namespace TapSDK.Core.Standalone
|
|
|
52
55
|
TapTapSdkOptions coreOptions = TapCoreStandalone.coreOptions;
|
|
53
56
|
if (coreOptions == null)
|
|
54
57
|
{
|
|
55
|
-
UIManager.Instance.OpenToast(
|
|
58
|
+
UIManager.Instance.OpenToast(
|
|
59
|
+
"IsLaunchedFromTapTapPC 调用必须在初始化之后",
|
|
60
|
+
UIManager.GeneralToastLevel.Error
|
|
61
|
+
);
|
|
56
62
|
TapLog.Error("IsLaunchedFromTapTapPC 调用必须在初始化之后");
|
|
57
63
|
return false;
|
|
58
64
|
}
|
|
@@ -60,8 +66,16 @@ namespace TapSDK.Core.Standalone
|
|
|
60
66
|
string pubKey = coreOptions.clientPublicKey;
|
|
61
67
|
if (string.IsNullOrEmpty(clientId) || string.IsNullOrEmpty(pubKey))
|
|
62
68
|
{
|
|
63
|
-
UIManager.Instance.OpenToast(
|
|
64
|
-
|
|
69
|
+
UIManager.Instance.OpenToast(
|
|
70
|
+
"clientId 及 TapPubKey 参数都不能为空, clientId ="
|
|
71
|
+
+ clientId
|
|
72
|
+
+ ", TapPubKey = "
|
|
73
|
+
+ pubKey,
|
|
74
|
+
UIManager.GeneralToastLevel.Error
|
|
75
|
+
);
|
|
76
|
+
TapLog.Error(
|
|
77
|
+
"clientId 或 TapPubKey 无效, clientId = " + clientId + ", TapPubKey = " + pubKey
|
|
78
|
+
);
|
|
65
79
|
return false;
|
|
66
80
|
}
|
|
67
81
|
isRuningIsLaunchedFromTapTapPC = true;
|
|
@@ -71,12 +85,19 @@ namespace TapSDK.Core.Standalone
|
|
|
71
85
|
try
|
|
72
86
|
{
|
|
73
87
|
TapInitResult result = await RunClientBridgeMethod(clientId, pubKey);
|
|
74
|
-
TapLog.Log(
|
|
88
|
+
TapLog.Log(
|
|
89
|
+
"check startupWithClientBridge finished thread = "
|
|
90
|
+
+ Thread.CurrentThread.ManagedThreadId
|
|
91
|
+
);
|
|
75
92
|
isRuningIsLaunchedFromTapTapPC = false;
|
|
76
93
|
if (result.needQuitGame)
|
|
77
94
|
{
|
|
78
95
|
lastIsLaunchedFromTapTapPCResult = 0;
|
|
79
|
-
TapCoreTracker.Instance.TrackSuccess(
|
|
96
|
+
TapCoreTracker.Instance.TrackSuccess(
|
|
97
|
+
TapCoreTracker.METHOD_LAUNCHER,
|
|
98
|
+
sessionId,
|
|
99
|
+
TapCoreTracker.SUCCESS_TYPE_RESTART
|
|
100
|
+
);
|
|
80
101
|
TapLog.Log("IsLaunchedFromTapTapPC Quit game");
|
|
81
102
|
#if UNITY_EDITOR
|
|
82
103
|
TapLog.Log(
|
|
@@ -94,13 +115,41 @@ namespace TapSDK.Core.Standalone
|
|
|
94
115
|
if (result.result == (int)TapSDKInitResult.OK)
|
|
95
116
|
{
|
|
96
117
|
string currentClientId;
|
|
97
|
-
bool isFetchClientIdSuccess = TapClientBridge.GetClientId(
|
|
118
|
+
bool isFetchClientIdSuccess = TapClientBridge.GetClientId(
|
|
119
|
+
out currentClientId
|
|
120
|
+
);
|
|
98
121
|
TapLog.Log("IsLaunchedFromTapTapPC get clientId = " + currentClientId);
|
|
99
|
-
if (
|
|
122
|
+
if (
|
|
123
|
+
isFetchClientIdSuccess
|
|
124
|
+
&& !string.IsNullOrEmpty(currentClientId)
|
|
125
|
+
&& currentClientId != clientId
|
|
126
|
+
)
|
|
100
127
|
{
|
|
101
|
-
UIManager.Instance.OpenToast(
|
|
102
|
-
|
|
103
|
-
|
|
128
|
+
UIManager.Instance.OpenToast(
|
|
129
|
+
"SDK 中配置的 clientId = "
|
|
130
|
+
+ clientId
|
|
131
|
+
+ "与 Tap 启动器中"
|
|
132
|
+
+ currentClientId
|
|
133
|
+
+ "不一致",
|
|
134
|
+
UIManager.GeneralToastLevel.Error
|
|
135
|
+
);
|
|
136
|
+
TapLog.Error(
|
|
137
|
+
"SDK 中配置的 clientId = "
|
|
138
|
+
+ clientId
|
|
139
|
+
+ "与 Tap 启动器中"
|
|
140
|
+
+ currentClientId
|
|
141
|
+
+ "不一致"
|
|
142
|
+
);
|
|
143
|
+
TapCoreTracker.Instance.TrackFailure(
|
|
144
|
+
TapCoreTracker.METHOD_LAUNCHER,
|
|
145
|
+
sessionId,
|
|
146
|
+
-1,
|
|
147
|
+
"SDK 中配置的 clientId = "
|
|
148
|
+
+ clientId
|
|
149
|
+
+ "与 Tap 启动器中"
|
|
150
|
+
+ currentClientId
|
|
151
|
+
+ "不一致"
|
|
152
|
+
);
|
|
104
153
|
lastIsLaunchedFromTapTapPCResult = 0;
|
|
105
154
|
return false;
|
|
106
155
|
}
|
|
@@ -109,7 +158,10 @@ namespace TapSDK.Core.Standalone
|
|
|
109
158
|
if (fetchOpenIdSuccess)
|
|
110
159
|
{
|
|
111
160
|
TapLog.Log("IsLaunchedFromTapTapPC get openId = " + openId);
|
|
112
|
-
EventManager.TriggerEvent(
|
|
161
|
+
EventManager.TriggerEvent(
|
|
162
|
+
EventManager.IsLaunchedFromTapTapPCFinished,
|
|
163
|
+
openId
|
|
164
|
+
);
|
|
113
165
|
}
|
|
114
166
|
else
|
|
115
167
|
{
|
|
@@ -117,20 +169,45 @@ namespace TapSDK.Core.Standalone
|
|
|
117
169
|
}
|
|
118
170
|
lastIsLaunchedFromTapTapPCResult = 1;
|
|
119
171
|
TapClientBridgePoll.StartUp();
|
|
120
|
-
TapCoreTracker.Instance.TrackSuccess(
|
|
172
|
+
TapCoreTracker.Instance.TrackSuccess(
|
|
173
|
+
TapCoreTracker.METHOD_LAUNCHER,
|
|
174
|
+
sessionId,
|
|
175
|
+
TapCoreTracker.SUCCESS_TYPE_INIT
|
|
176
|
+
);
|
|
121
177
|
TapLog.Log("IsLaunchedFromTapTapPC check success");
|
|
178
|
+
// 如果开发者已经注册了监听客户端运行状态,此时添加对应回调
|
|
179
|
+
if (
|
|
180
|
+
taptapPCStateChangeListeners != null
|
|
181
|
+
&& taptapPCStateChangeListeners.Count > 0
|
|
182
|
+
&& !hasRegisterSystemListener
|
|
183
|
+
)
|
|
184
|
+
{
|
|
185
|
+
TapClientBridge.RegisterSystemStateCallback(TapTapPCStateDelegate);
|
|
186
|
+
hasRegisterSystemListener = true;
|
|
187
|
+
}
|
|
122
188
|
return true;
|
|
123
189
|
}
|
|
124
190
|
else
|
|
125
191
|
{
|
|
126
|
-
|
|
127
|
-
|
|
192
|
+
TapCoreTracker.Instance.TrackFailure(
|
|
193
|
+
TapCoreTracker.METHOD_LAUNCHER,
|
|
194
|
+
sessionId,
|
|
195
|
+
(int)result.result,
|
|
196
|
+
result.errorMsg ?? ""
|
|
197
|
+
);
|
|
128
198
|
lastIsLaunchedFromTapTapPCResult = 0;
|
|
129
|
-
TapLog.Log(
|
|
199
|
+
TapLog.Log(
|
|
200
|
+
"IsLaunchedFromTapTapPC show TapClient tip Pannel "
|
|
201
|
+
+ result.result
|
|
202
|
+
+ " , error = "
|
|
203
|
+
+ result.errorMsg
|
|
204
|
+
);
|
|
130
205
|
string tipPannelPath = "Prefabs/TapClient/TapClientConnectTipPanel";
|
|
131
206
|
if (Resources.Load<GameObject>(tipPannelPath) != null)
|
|
132
207
|
{
|
|
133
|
-
var pannel = UIManager.Instance.OpenUI<TapClientConnectTipController>(
|
|
208
|
+
var pannel = UIManager.Instance.OpenUI<TapClientConnectTipController>(
|
|
209
|
+
tipPannelPath
|
|
210
|
+
);
|
|
134
211
|
pannel.Show(result.result);
|
|
135
212
|
}
|
|
136
213
|
return false;
|
|
@@ -140,30 +217,50 @@ namespace TapSDK.Core.Standalone
|
|
|
140
217
|
catch (Exception e)
|
|
141
218
|
{
|
|
142
219
|
lastIsLaunchedFromTapTapPCResult = 0;
|
|
143
|
-
TapCoreTracker.Instance.TrackFailure(
|
|
144
|
-
|
|
145
|
-
|
|
220
|
+
TapCoreTracker.Instance.TrackFailure(
|
|
221
|
+
TapCoreTracker.METHOD_LAUNCHER,
|
|
222
|
+
sessionId,
|
|
223
|
+
(int)TapSDKInitResult.Unknown,
|
|
224
|
+
e.Message ?? ""
|
|
225
|
+
);
|
|
226
|
+
|
|
227
|
+
TapLog.Log(
|
|
228
|
+
"IsLaunchedFromTapTapPC check exception = " + e.Message + " \n" + e.StackTrace
|
|
229
|
+
);
|
|
146
230
|
string tipPannelPath = "Prefabs/TapClient/TapClientConnectTipPanel";
|
|
147
231
|
if (Resources.Load<GameObject>(tipPannelPath) != null)
|
|
148
232
|
{
|
|
149
|
-
var pannel = UIManager.Instance.OpenUI<TapClientConnectTipController>(
|
|
233
|
+
var pannel = UIManager.Instance.OpenUI<TapClientConnectTipController>(
|
|
234
|
+
tipPannelPath
|
|
235
|
+
);
|
|
150
236
|
pannel.Show((int)TapSDKInitResult.Unknown);
|
|
151
237
|
}
|
|
152
238
|
return false;
|
|
153
239
|
}
|
|
154
240
|
}
|
|
155
241
|
|
|
156
|
-
private static async Task<TapInitResult> RunClientBridgeMethod(
|
|
242
|
+
private static async Task<TapInitResult> RunClientBridgeMethod(
|
|
243
|
+
string clientId,
|
|
244
|
+
string pubKey
|
|
245
|
+
)
|
|
157
246
|
{
|
|
158
247
|
TaskCompletionSource<TapInitResult> task = new TaskCompletionSource<TapInitResult>();
|
|
159
248
|
try
|
|
160
249
|
{
|
|
161
250
|
await Task.Run(() =>
|
|
162
251
|
{
|
|
163
|
-
TapLog.Log(
|
|
252
|
+
TapLog.Log(
|
|
253
|
+
"check startupWithClientBridge start thread = "
|
|
254
|
+
+ Thread.CurrentThread.ManagedThreadId
|
|
255
|
+
);
|
|
164
256
|
bool needQuitGame = TapClientBridge.TapSDK_RestartAppIfNecessary(clientId);
|
|
165
|
-
TapLog.Log(
|
|
166
|
-
|
|
257
|
+
TapLog.Log(
|
|
258
|
+
"RunClientBridgeMethodWithTimeout invoke TapSDK_RestartAppIfNecessary result = "
|
|
259
|
+
+ needQuitGame
|
|
260
|
+
);
|
|
261
|
+
TapLog.Log(
|
|
262
|
+
"RunClientBridgeMethodWithTimeout invoke TapSDK_RestartAppIfNecessary finished "
|
|
263
|
+
);
|
|
167
264
|
if (needQuitGame)
|
|
168
265
|
{
|
|
169
266
|
tapInitResult = new TapInitResult(needQuitGame);
|
|
@@ -171,13 +268,20 @@ namespace TapSDK.Core.Standalone
|
|
|
171
268
|
else
|
|
172
269
|
{
|
|
173
270
|
string outputError;
|
|
174
|
-
int tapSDKInitResult = TapClientBridge.CheckInitState(
|
|
175
|
-
|
|
271
|
+
int tapSDKInitResult = TapClientBridge.CheckInitState(
|
|
272
|
+
out outputError,
|
|
273
|
+
pubKey
|
|
274
|
+
);
|
|
275
|
+
TapLog.Log(
|
|
276
|
+
"RunClientBridgeMethodWithTimeout invoke CheckInitState result = "
|
|
277
|
+
+ tapSDKInitResult
|
|
278
|
+
+ ", error = "
|
|
279
|
+
+ outputError
|
|
280
|
+
);
|
|
176
281
|
tapInitResult = new TapInitResult(tapSDKInitResult, outputError);
|
|
177
282
|
}
|
|
178
283
|
task.TrySetResult(tapInitResult);
|
|
179
284
|
});
|
|
180
|
-
|
|
181
285
|
}
|
|
182
286
|
catch (Exception ex)
|
|
183
287
|
{
|
|
@@ -195,148 +299,61 @@ namespace TapSDK.Core.Standalone
|
|
|
195
299
|
return isChannelPackage;
|
|
196
300
|
}
|
|
197
301
|
|
|
198
|
-
public static bool isPassedInLaunchedFromTapTapPCCheck()
|
|
302
|
+
public static bool isPassedInLaunchedFromTapTapPCCheck()
|
|
303
|
+
{
|
|
199
304
|
return lastIsLaunchedFromTapTapPCResult > 0;
|
|
200
305
|
}
|
|
201
306
|
|
|
202
|
-
|
|
203
|
-
private static
|
|
204
|
-
|
|
307
|
+
private static HashSet<Action<int>> taptapPCStateChangeListeners;
|
|
308
|
+
private static volatile bool hasRegisterSystemListener = false;
|
|
205
309
|
/// <summary>
|
|
206
|
-
///
|
|
310
|
+
/// 设置 TapPC 客户端状态监听
|
|
207
311
|
/// </summary>
|
|
208
|
-
|
|
209
|
-
string codeChallenge, string state, string codeChallengeMethod, string versonCode, string sdkUa, string info, Action<bool, string> callback)
|
|
312
|
+
internal static void RegisterTapTapPCStateChangeListener(Action<int> action)
|
|
210
313
|
{
|
|
211
|
-
if (
|
|
314
|
+
if (taptapPCStateChangeListeners == null)
|
|
212
315
|
{
|
|
213
|
-
|
|
214
|
-
TapLog.Error(" login must be invoked after IsLaunchedFromTapTapPC success");
|
|
215
|
-
throw new Exception("login must be invoked after IsLaunchedFromTapTapPC success");
|
|
316
|
+
taptapPCStateChangeListeners = new HashSet<Action<int>>();
|
|
216
317
|
}
|
|
217
|
-
|
|
218
|
-
|
|
318
|
+
taptapPCStateChangeListeners.Add(action);
|
|
319
|
+
if (isPassedInLaunchedFromTapTapPCCheck() && !hasRegisterSystemListener)
|
|
219
320
|
{
|
|
220
|
-
TapClientBridge.
|
|
221
|
-
|
|
222
|
-
codeChallenge, state, codeChallengeMethod, versonCode, sdkUa, info);
|
|
223
|
-
TapLog.Log("LoginWithScopes start result = " + authorizeResult);
|
|
224
|
-
if (authorizeResult != AuthorizeResult.OK)
|
|
225
|
-
{
|
|
226
|
-
TapClientBridge.UnRegisterCallback(TapEventID.AuthorizeFinished_internal,loginCallbackDelegate);
|
|
227
|
-
return false;
|
|
228
|
-
}
|
|
229
|
-
else
|
|
230
|
-
{
|
|
231
|
-
currentLoginCallback = callback;
|
|
232
|
-
return true;
|
|
233
|
-
}
|
|
234
|
-
|
|
321
|
+
TapClientBridge.RegisterSystemStateCallback(TapTapPCStateDelegate);
|
|
322
|
+
hasRegisterSystemListener = true;
|
|
235
323
|
}
|
|
236
|
-
catch (Exception ex)
|
|
237
|
-
{
|
|
238
|
-
TapLog.Log("LoginWithScopes start login by tapclient error = " + ex.Message);
|
|
239
|
-
TapClientBridge.UnRegisterCallback(TapEventID.AuthorizeFinished_internal,loginCallbackDelegate);
|
|
240
|
-
return false;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
324
|
}
|
|
244
325
|
|
|
245
|
-
|
|
246
|
-
[AOT.MonoPInvokeCallback(typeof(TapClientBridge.CallbackDelegate))]
|
|
247
|
-
static void loginCallbackDelegate(int id, IntPtr userData)
|
|
326
|
+
internal static void UnRegisterTapTapPCStateChangeListener(Action<int> action)
|
|
248
327
|
{
|
|
249
|
-
|
|
250
|
-
if (id == (int)TapEventID.AuthorizeFinished_internal)
|
|
328
|
+
if (taptapPCStateChangeListeners != null && taptapPCStateChangeListeners.Count > 0)
|
|
251
329
|
{
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
TapLog.Log("LoginWithScopes callback = " + response.is_cancel + " uri = " + response.callback_uri);
|
|
255
|
-
if (currentLoginCallback != null)
|
|
330
|
+
taptapPCStateChangeListeners.Remove(action);
|
|
331
|
+
if (taptapPCStateChangeListeners.Count == 0)
|
|
256
332
|
{
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
currentLoginCallback = null;
|
|
333
|
+
TapClientBridge.UnRegisterSystemStateCallback(TapTapPCStateDelegate);
|
|
334
|
+
hasRegisterSystemListener = false;
|
|
260
335
|
}
|
|
261
336
|
}
|
|
262
337
|
}
|
|
263
|
-
|
|
264
|
-
// DLC 相关功能
|
|
265
|
-
private static Action<string, bool> currentDlcDelegate;
|
|
266
|
-
private static Action<bool> currentLicenseDelegate;
|
|
267
|
-
|
|
268
|
-
/// 查询是否购买 DLC , 未调用 isLaunchFromPC 会抛异常
|
|
269
|
-
public static bool QueryDLC(string skuId)
|
|
270
|
-
{
|
|
271
|
-
if (lastIsLaunchedFromTapTapPCResult != 1)
|
|
272
|
-
{
|
|
273
|
-
throw new Exception("queryDLC must be invoked after IsLaunchedFromTapTapPC success");
|
|
274
|
-
}
|
|
275
|
-
bool success = TapClientBridge.QueryDLC(skuId);
|
|
276
|
-
return success;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/// 跳转到 TapTap 客户端 DLC 购买页面 , 未调用 isLaunchFromPC 会抛异常
|
|
280
|
-
public static bool ShowStore(string skuId)
|
|
281
|
-
{
|
|
282
|
-
if (lastIsLaunchedFromTapTapPCResult != 1)
|
|
283
|
-
{
|
|
284
|
-
throw new Exception("purchaseDLC must be invoked after IsLaunchedFromTapTapPC success");
|
|
285
|
-
}
|
|
286
|
-
TapLog.Log("purchaseDLC start = " + skuId);
|
|
287
|
-
return TapClientBridge.TapDLC_ShowStore(skuId);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/// 注册 DLC 购买状态变更回调,包括购买成功和退款
|
|
291
|
-
public static void RegisterDLCOwnedCallback(Action<string, bool> dlcDelegate)
|
|
292
|
-
{
|
|
293
|
-
currentDlcDelegate = dlcDelegate;
|
|
294
|
-
TapClientBridge.RegisterCallback(TapEventID.DLCPlayableStatusChanged, DLCCallbackDelegate);
|
|
295
|
-
}
|
|
296
338
|
|
|
297
|
-
/// DLC 回调
|
|
298
339
|
[AOT.MonoPInvokeCallback(typeof(TapClientBridge.CallbackDelegate))]
|
|
299
|
-
static void
|
|
340
|
+
static void TapTapPCStateDelegate(int id, IntPtr userData)
|
|
300
341
|
{
|
|
301
|
-
|
|
302
|
-
if (currentDlcDelegate != null)
|
|
342
|
+
if (id == (int)TapEventID.SystemStateChanged)
|
|
303
343
|
{
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
TapClientBridge.RegisterCallback(TapEventID.GamePlayableStatusChanged, LicenseCallbackDelegate);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/// License 回调
|
|
318
|
-
[AOT.MonoPInvokeCallback(typeof(TapClientBridge.CallbackDelegate))]
|
|
319
|
-
static void LicenseCallbackDelegate(int id, IntPtr userData)
|
|
320
|
-
{
|
|
321
|
-
TapLog.Log("License recevie callback " + id);
|
|
322
|
-
if (currentLicenseDelegate != null)
|
|
323
|
-
{
|
|
324
|
-
TapClientBridge.GamePlayableStatusChangedResponse response = Marshal.PtrToStructure<TapClientBridge.GamePlayableStatusChangedResponse>(userData);
|
|
325
|
-
TapLog.Log("License callback isOwn changed " + response.is_playable );
|
|
326
|
-
currentLicenseDelegate(response.is_playable != 0);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
public static bool HasLicense()
|
|
331
|
-
{
|
|
332
|
-
if (lastIsLaunchedFromTapTapPCResult != 1)
|
|
333
|
-
{
|
|
334
|
-
throw new Exception("checkLicense must be invoked after IsLaunchedFromTapTapPC success");
|
|
344
|
+
SystemStateResponse response = Marshal.PtrToStructure<SystemStateResponse>(
|
|
345
|
+
userData
|
|
346
|
+
);
|
|
347
|
+
if (taptapPCStateChangeListeners != null)
|
|
348
|
+
{
|
|
349
|
+
foreach (var listener in taptapPCStateChangeListeners)
|
|
350
|
+
{
|
|
351
|
+
listener(response.state);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
335
354
|
}
|
|
336
|
-
return TapClientBridge.HasLicense();
|
|
337
355
|
}
|
|
338
356
|
|
|
339
|
-
|
|
340
357
|
// 初始化校验结果
|
|
341
358
|
private class TapInitResult
|
|
342
359
|
{
|
|
@@ -248,6 +248,18 @@ namespace TapSDK.Core.Standalone
|
|
|
248
248
|
{
|
|
249
249
|
TapOpenlogStandalone.LogBusiness(project, version, action, properties);
|
|
250
250
|
}
|
|
251
|
+
|
|
252
|
+
#if UNITY_STANDALONE_WIN
|
|
253
|
+
public void RegisterTapTapPCStateChangeListener(Action<int> action)
|
|
254
|
+
{
|
|
255
|
+
TapClientStandalone.RegisterTapTapPCStateChangeListener(action);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
public void UnRegisterTapTapPCStateChangeListener(Action<int> action)
|
|
259
|
+
{
|
|
260
|
+
TapClientStandalone.UnRegisterTapTapPCStateChangeListener(action);
|
|
261
|
+
}
|
|
262
|
+
#endif
|
|
251
263
|
}
|
|
252
264
|
|
|
253
265
|
|