Skip to content

Commit

Permalink
feat:update upm
Browse files Browse the repository at this point in the history
  • Loading branch information
dango2887 committed Oct 22, 2024
0 parents commit 9f33503
Show file tree
Hide file tree
Showing 43 changed files with 712 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Mobile.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Mobile/Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Mobile/Editor/NativeDependencies.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" ?>
<dependencies>
<androidPackages>
<repositories>
<repository>https://repo.maven.apache.org/maven2</repository>
</repositories>
<androidPackage spec="com.taptap.sdk:tap-license:4.4.2"/>
</androidPackages>
</dependencies>
7 changes: 7 additions & 0 deletions Mobile/Editor/NativeDependencies.xml.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions Mobile/Editor/TapLicenseMobileProcessBuild.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using UnityEditor.Build.Reporting;
using TapSDK.Core.Editor;

namespace TapSDK.License.Mobile.Editor {
public class TapLicenseMobileProcessBuild : SDKLinkProcessBuild {
public override int callbackOrder => 0;

public override string LinkPath => "TapSDK/License/link.xml";

public override LinkedAssembly[] LinkedAssemblies => new LinkedAssembly[] {
new LinkedAssembly { Fullname = "TapSDK.License.Runtime" },
new LinkedAssembly { Fullname = "TapSDK.License.Mobile.Runtime" }
};

public override Func<BuildReport, bool> IsTargetPlatform => (report) => {
return BuildTargetUtils.IsSupportMobile(report.summary.platform);
};
}
}
11 changes: 11 additions & 0 deletions Mobile/Editor/TapLicenseMobileProcessBuild.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions Mobile/Editor/TapSDK.License.Mobile.Editor.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "TapSDK.License.Mobile.Editor",
"references": [
"GUID:56f3da7a178484843974054bafe77e73"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions Mobile/Editor/TapSDK.License.Mobile.Editor.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Mobile/Runtime.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

159 changes: 159 additions & 0 deletions Mobile/Runtime/TapLicenseMobile.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
using System.Collections.Generic;
using TapSDK.License.Internal;
using TapSDK.Core;

namespace TapSDK.License.Mobile
{
public class TapLicenseMobile : ITapLicenseBridge
{
public static string TAP_LICENSE_SERVICE = "BridgeLicenseService";

public static string TDS_LICENSE_SERVICE_CLZ = "com.taptap.sdk.license.internal.enginebridge.BridgeLicenseService";

public static string TDS_LICENSE_SERVICE_IMPL = "com.taptap.sdk.license.internal.enginebridge.BridgeLicenseServiceImpl";

public TapLicenseMobile()
{
EngineBridge.GetInstance().Register(TDS_LICENSE_SERVICE_CLZ, TDS_LICENSE_SERVICE_IMPL);
}

public void RegisterLicencesCallback(ITapLicenseCallback callback)
{
var command = new Command.Builder()
.Service(TAP_LICENSE_SERVICE)
.Method("registerLicenseCallback")
.Callback(true)
.OnceTime(false)
.CommandBuilder();
EngineBridge.GetInstance().CallHandler(command, (result) =>
{
if (result.code != Result.RESULT_SUCCESS)
{
return;
}
if (string.IsNullOrEmpty(result.content))
{
return;
}
var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
var success = SafeDictionary.GetValue<string>(dic, "login") as string;
if (success.Equals("success"))
{
callback.OnLicenseSuccess();
}
});
}

public void RegisterDLCCallback(ITapDlcCallback callback)
{
var command = new Command.Builder();
command.Service(TAP_LICENSE_SERVICE);
command.Method("registerDLCCallback")
.Callback(true)
.OnceTime(false);

EngineBridge.GetInstance().CallHandler(command.CommandBuilder(), (result) =>
{
if (result.code != Result.RESULT_SUCCESS)
{
return;
}
if (string.IsNullOrEmpty(result.content))
{
return;
}
var dic = Json.Deserialize(result.content) as Dictionary<string, object>;
var dlc = SafeDictionary.GetValue<string>(dic, "orderDLC");
if (!string.IsNullOrEmpty(dlc))
{
var statusCode = SafeDictionary.GetValue<int>(dic, "orderStatus");
callback.OnOrderCallBack(dlc, HandlePurchasedCode(statusCode));
return;
}
var code = SafeDictionary.GetValue<int>(dic, "queryCode");
var queryListJson = SafeDictionary.GetValue<string>(dic, "queryResult");
var queryListDic = Json.Deserialize(queryListJson) as Dictionary<string, object>;
callback.OnQueryCallBack(HandleQueryCode(code), queryListDic);
});
}

private static TapLicenseQueryCode HandleQueryCode(int code)
{
switch (code)
{
case 0:
return TapLicenseQueryCode.QUERY_RESULT_OK;
case 1:
return TapLicenseQueryCode.QUERY_RESULT_NOT_INSTALL_TAPTAP;
case 2:
return TapLicenseQueryCode.QUERY_RESULT_ERR;
default:
return TapLicenseQueryCode.ERROR_CODE_UNDEFINED;
}
}

private static TapLicensePurchasedCode HandlePurchasedCode(int code)
{
switch (code)
{
case 0:
return TapLicensePurchasedCode.DLC_NOT_PURCHASED;
case 1:
return TapLicensePurchasedCode.DLC_PURCHASED;
case -1:
return TapLicensePurchasedCode.DLC_RETURN_ERROR;
default:
return TapLicensePurchasedCode.ERROR_CODE_UNDEFINED;
}
}

public void CheckLicense()
{
var command = new Command.Builder()
.Service(TAP_LICENSE_SERVICE)
.Method("checkLicense")
.CommandBuilder();
EngineBridge.GetInstance().CallHandler(command);
}

public void CheckLicenseForcibly(){
var command = new Command.Builder()
.Service(TAP_LICENSE_SERVICE)
.Method("checkLicenseForcibly")
.CommandBuilder();
EngineBridge.GetInstance().CallHandler(command);
}

public void QueryDLC(string[] skus)
{
var command = new Command.Builder()
.Service(TAP_LICENSE_SERVICE)
.Method("queryDLC")
.Args("skuList", skus)
.CommandBuilder();
EngineBridge.GetInstance().CallHandler(command);
}

public void PurchaseDLC(string sku)
{
var command = new Command.Builder()
.Service(TAP_LICENSE_SERVICE)
.Method("purchaseDLC")
.Args("skuId", sku)
.CommandBuilder();
EngineBridge.GetInstance().CallHandler(command);
}

public void SetTestEnvironment(bool isTest){
var command = new Command.Builder()
.Service(TAP_LICENSE_SERVICE)
.Method("setTestEnvironment")
.Args("testEnv", isTest)
.CommandBuilder();
EngineBridge.GetInstance().CallHandler(command);
}

}
}
11 changes: 11 additions & 0 deletions Mobile/Runtime/TapLicenseMobile.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions Mobile/Runtime/TapSDK.License.Mobile.Runtime.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "TapSDK.License.Mobile.Runtime",
"references": [
"GUID:6f31234cd7bae42d2ae6f8b300cad891",
"GUID:7d5ef2062f3704e1ab74aac0e4d5a1a7",
"GUID:10560023d8780423cb943c7a324b69f2"
],
"includePlatforms": [
"Android",
"iOS"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions Mobile/Runtime/TapSDK.License.Mobile.Runtime.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Runtime.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Runtime/Internal.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Runtime/Internal/ITapLicenseBridge.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

namespace TapSDK.License.Internal {
public interface ITapLicenseBridge {
void RegisterLicencesCallback(ITapLicenseCallback callback);

void RegisterDLCCallback(ITapDlcCallback callback);

void CheckLicense();

void CheckLicenseForcibly();

void QueryDLC(string[] skus);

void PurchaseDLC(string sku);

void SetTestEnvironment(bool isTest);

}
}
11 changes: 11 additions & 0 deletions Runtime/Internal/ITapLicenseBridge.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Runtime/Public.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Runtime/Public/ITapDlcCallback.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System.Collections.Generic;

namespace TapSDK.License {
public interface ITapDlcCallback {
void OnQueryCallBack(TapLicenseQueryCode code, Dictionary<string, object> queryList);
void OnOrderCallBack(string sku, TapLicensePurchasedCode status);
}
}
11 changes: 11 additions & 0 deletions Runtime/Public/ITapDlcCallback.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Runtime/Public/ITapLicenseCallback.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace TapSDK.License {
public interface ITapLicenseCallback {
void OnLicenseSuccess();
}
}
Loading

0 comments on commit 9f33503

Please sign in to comment.