feat:update upm

3.18.2-alpha1
ci-gitlab 2023-03-20 14:37:07 +08:00
commit 56f928a2f5
18 changed files with 1108 additions and 0 deletions

260
CHANGELOG.md Normal file
View File

@ -0,0 +1,260 @@
# ChangeLog
## 3.11.1
- TapTap.Login v3.11.1
- TapTap.Common v3.11.1
- LeanCloud.Realtime v0.10.11
- LeanCloud.Storage v0.10.11
## 3.11.0
### Dependencies
- TapTap.Login v3.11.0
- TapTap.Common v3.11.0
- LeanCloud.Realtime v0.10.11
- LeanCloud.Storage v0.10.11
## 3.10.0
### New Feature
- 支持排行榜
### Dependencies
- TapTap.Login v3.10.0
- TapTap.Common v3.10.0
- LeanCloud.Realtime v0.10.11
- LeanCloud.Storage v0.10.11
## 3.9.0
### Dependencies
- TapTap.Login v3.9.0
- TapTap.Common v3.9.0
- LeanCloud.Realtime v0.10.11
- LeanCloud.Storage v0.10.11
## 3.8.0
### Dependencies
- TapTap.Login v3.8.0
- TapTap.Common v3.8.0
- LeanCloud.Realtime v0.10.10
- LeanCloud.Storage v0.10.10
## 3.7.1
### Dependencies
- TapTap.Login v3.7.1
- TapTap.Common v3.7.1
- LeanCloud.Realtime v0.10.0
- LeanCloud.Storage v0.10.0
## 3.7.0
### Dependencies
- TapTap.Login v3.7.0
- TapTap.Common v3.7.0
- LeanCloud.Realtime v0.10.0
- LeanCloud.Storage v0.10.0
## 3.6.3
### Dependencies
- TapTap.Login v3.6.3
- TapTap.Common v3.6.3
- LeanCloud.Realtime v0.10.0
- LeanCloud.Storage v0.10.0
## 3.6.1
### Dependencies
- TapTap.Login v3.6.1
- TapTap.Common v3.6.1
- LeanCloud.Realtime v0.10.0
- LeanCloud.Storage v0.10.0
## 3.6.0
### Dependencies
- TapTap.Login v3.6.0
- TapTap.Common v3.6.0
- LeanCloud.Realtime v0.10.0
- LeanCloud.Storage v0.10.0
## 3.5.0
### Dependencies
- TapTap.Login v3.5.0
- TapTap.Common v3.5.0
- LeanCloud.Realtime v0.10.0
- LeanCloud.Storage v0.10.0
## 3.4.0
### Dependencies
- TapTap.Login v3.4.0
- TapTap.Common v3.4.0
- LeanCloud.Realtime v0.10.0
- LeanCloud.Storage v0.10.0
## 3.3.0
### Dependencies
- TapTap.Login v3.3.0
- TapTap.Common v3.3.0
- LeanCloud.Realtime v0.9.11
- LeanCloud.Storage v0.9.11
## 3.2.0
### New Feature
- 支持云存档
### Dependencies
- TapTap.Login v3.2.0
- TapTap.Common v3.2.0
- LeanCloud.Storage v0.9.5
- LeanCloud.Realtime v0.9.5
## 3.1.0
### New Feature
- `TDSUser` 新增好友系统操作
### Dependencies
- TapTap.Login v3.1.0
- TapTap.Common v3.1.0
- LeanCloud.Storage v0.9.2
- LeanCloud.Realtime v0.9.2
## 3.0.0
TapSDK 3.0 开始,我们在单纯的 TapTap 登录之外,还提供了一个内建账户系统供游戏使用:开发者可以直接用 TapTap OAuth
授权的结果生成一个游戏内的账号TDSUser然后用该账号保存更多玩家数据。同时我们也支持将更多第三方认证登录的结果绑定到这一账号上来以及后续的解绑操作
### New Feature
- 新增 `TDSUser` 用于内建账户系统操作
### BreakingChange
- `TapBootstrap` 接口仅保留 `TapBootstrap.Init(tapConfig)` 接口
### Dependencies
- LeanCloud.Storage v0.8.2
- TapTap.Login v3.0.0
- TapTap.Common v3.0.0
## 2.1.7
### Dependencies
- TapTap.Common v2.1.7
## 2.1.6
### Dependencies
- TapTap.Common v2.1.6
## 2.1.5
### Dependencies
- TapTap.Common v2.1.5
## 2.1.4
### Optimization and fixed bugs
- 优化多语言相关
### Dependencies
- TapTap.Common v2.1.4
## 2.1.3
### Feature
* 新增繁中、日文、韩文、泰文和印尼语多语言配置
## 2.1.2
### BreakingChange
* 废弃 OpenUserCenter 接口
### Dependencies
* TapTap.Common v2.1.2
## 2.1.1
### Feature
* 新增篝火测试资格校验
```
TapBootstrap.GetTestQualification((bool, error)=>{ }):
```
* 通过 TapConfig 进行初始化配置
* 新增 TapDBConfig 用于 TapDB 初始化配置
* 新增 ClientSecret 用于 TapSDK 初始化
```c#
//建议使用以下 TapConfig 构造方法进行初始化
var config = new TapConfig.Builder()
.ClientID("client_id")
.ClientSecret("client_secret")
.RegionType(RegionType.CN)
.TapDBConfig(true, "gameChannel", "gameVersion", true)
.ConfigBuilder();
TapBootstrap.Init(config);
```
### Breaking changes
* LoginType 删除 Apple、Guest 登陆方式
* TDS-Info.plist 删除 Apple_SignIn_Enable 配置
* 废弃 Bind 接口
* TapConfig 构造方法参数修改
### Dependencies
* TapTap.Common v2.1.1
## 2.1.0
### Feature
* 支持性改动用于 TapTap.Friends
### Dependencies
* TapTap.Common v2.1.0
## 2.0.0
### Feature
* TapTap Bootstrap
### Dependencies
* TapTap.Common v2.0.0

3
CHANGELOG.md.meta Normal file
View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7388165be5344a9682382768c5fce466
timeCreated: 1616755935

8
Documentation.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bd03b50332353477c899419b5b455fb0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

257
Documentation/README.md Normal file
View File

@ -0,0 +1,257 @@
# 使用 TapTap.Bootstrap
## 使用前提
使用 TapTap.Bootstrap 前提是必须依赖以下库:
* [TapTap.Common](https://github.com/TapTap/TapCommon-Unity.git)
* [TapTap.Login](https://github.com/TapTap/TapLogin-Unity.git)
* [LeanCloud.Storage](https://github.com/leancloud/csharp-sdk)
* [LeanCloud.RealTime](https://github.com/leancloud/csharp-sdk)
## 命名空间
```c#
using TapTap.Bootstrap;
```
## 接口描述
## 1.初始化
TapBootstrap 会根据 TapConfig 中的 TapDBConfig 配置来进行 TapDB 的自动初始化。
### 开启 TapDB
```c#
var config = new TapConfig.Builder()
.ClientID("client_id")
.ClientToken("client_token")
.ServerURL("https://ikggdre2.lc-cn-n1-shared.com")
.RegionType(RegionType.CN)
.TapDBConfig(true,"channel","gameVersion",true)
.Builder();
```
### 关闭 TapDB
```c#
var config = new TapConfig.Builder()
.ClientID("client_id")
.ClientToken("client_token")
.ServerURL("https://ikggdre2.lc-cn-n1-shared.com")
.RegionType(RegionType.CN)
//# .TapDBConfig(false,null,null,false)
.EnableTapDB(false)
.Builder();
```
### 初始化
```c#
TapBootstrap.Init(config);
```
## 2.账户系统
> 登陆成功之后,都会得到一个 `TDSUser` 实例
### 使用 TapTap OAuth 授权结果直接登陆/注册账户系统
```c#
var tdsUser = await TDSUser.LoginWithTapTap();
```
### 游客登陆
```c#
var tdsUser = await TDSUser.LoginAnonymously();
```
### 使用第三方平台授权登录/注册账户
```c#
var tdsUser = await TDSUser.LoginWithAuthData(Dictionary<string, object> authData, string platform,
LCUserAuthDataLoginOption option = null);
```
### 绑定第三方平台授权
```c#
await TDSUser.AssociateAuthData(Dictionary<string, object> authData, string platform);
```
### 退出登陆
```c#
TDSUser.Logout();
```
## 3.好友系统
### 申请成为好友
```c#
TDSUser tom, jerry;
await tom.ApplyFriendship(jerry);
```
申请成功的回调中,我们会得到一个 LCFriendshipRequest 的实例,这个实例中包含了两个用户:
- sourceUser指请求的发起方上面的例子中就是 `tom`
- friend指请求的目的方上面的例子中就是 `jerry`
tom 也可以在申请好友的时候,添加更多的属性,例如 tom 希望加 jerry 为好友的时候,也设定一个名为 cat 的圈子,可以这样操作:
```cs
Dictionary<string, object> attrs = new Dictionary<string, object> {
{ "group", "cat" }
};
await tom.ApplyFriendship(jerry, attrs);
```
### 获取好友申请列表
好友申请有三种状态:
- `pending`,对方没有回应,还处于等待中。
- `accepted`,对方已经接受,现在双方成为好友。
- `declined`,对方已经拒绝。
好友请求创建之后默认是 `pending` 状态。
jerry 这里可以通过 `friendshipRequestQuery` 来查找不同状态的请求。例如 jerry 想看看新的好友请求,可以这样操作:
```cs
LCQuery<LCFriendshipRequest> query = jerry.GetFriendshipRequestQuery(LCFriendshipRequest.STATUS_PENDING, false, true);
ReadOnlyCollection<LCFriendshipRequest> reqs = await query.Find();
foreach (LCFriendshipRequest req in reqs) {
Console.WriteLine(req);
}
```
### 处理好友申请
jerry 对于新的好友请求,可以同意或者拒绝,也可以什么都不做,无视这些请求,甚至直接删除。这些操作我们都是支持的,请看下面的示例:
```cs
LCFriendshipRequest tomRequest, tuffyRequest, otherRequest;
await jerry.AcceptFriendshipRequest(tomRequest);
await jerry.DeclineFriendshipRequest(tuffyRequest);
await jerry.DeleteFriendshipRequest(otherRequest);
```
注意:
* 在 jerry 拒绝了 tom 的好友请求之后,如果 tom 再次请求成为 jerry 的好友tom 在执行 applyFriendshipInBackground 时会直接得到错误的应答,表明 jerry 不想和 ta 成为好友。
* jerry 同意了 tuffy 的好友请求之后,它们就成为了好友,之后两个人中任何一人再次调用 applyFriendshipInBackground 申请横位好友时,也会直接得到错误的应答,表明它们已经是好友无需再次申请。
* jerry 删除陌生人的好友请求后,对方还可以再次发起请求。
### 响应好友变化通知
TDS 好友模块支持客户端监听好友状态变化,在游戏中实时给玩家提示。好友状态变化的接口包括
```cs
public class FriendshipNotification {
public Action<LCFriendshipRequest> OnNewRequestComing { get; set; }
public Action<LCFriendshipRequest> OnRequestAccepted { get; set; }
public Action<LCFriendshipRequest> OnRequestDeclined { get; set; }
}
```
其中:
- onNewRequestComing 表示有其他人申请成为当前用户的好友,通过调用 `LCFriendshipRequest#getSourceUser()` 方法可以获得发起方用户信息。
- onRequestAccepted 表示当前用户的好友申请被对方通过,通过调用 `LCFriendshipRequest#getFriend()` 方法可以获得对方用户信息。
- onRequestDeclined 表示当前用户的好友申请被对方拒绝,通过调用 `LCFriendshipRequest#getFriend()` 方法可以获得对方用户信息。
开发者可以通过 `TDSUser#registerFriendshipNotification` 来注册通知接收器,通过调用 `TDSUser#unregisterFriendshipNotification` 来取消通知接收器。
### 获取好友列表
调用 `TDSUser#friendshipQuery()` 可以得到查询好友的 `LCQuery` 实例,之后调用 `LCQuery#findInBackground()` 方法就可以得到好友列表。示例如下:
```cs
LCQuery<LCObject> query = jerry.GetFirendshipQuery();
```
LCFriendship 里面会包含两个用户:
- `LCFriendship#getLCUser(LCFriendship.ATTR_USER)` 得到的是 jerry 自己;
- `LCFriendship#getLCUser(LCFriendship.ATTR_FOLLOWEE)` 得到的就是另一方的用户信息。
### 删除好友
成为好友关系的两个用户,之后也可以单方面删除好友。例如 jerry 不想再和 tom 成为好友,那只需要在自己的好友列表中删除包含 tom 的那条 LCFriendship 记录即可:
```cs
await friendship.Delete();
```
### 查询好友关系
我们使用 LCQuery 可以单独查询两个用户是否为好友关系。
```cs
LCQuery<LCObject> query = jerry.GetFirendshipQuery();
query.whereEqualTo("followee", tom);
int count = await query.Count();
if (count > 0) {
// tom is a friend of jerry.
} else {
// tom isn't a friend of jerry.
}
```
这一查询是通过网络发送到服务端执行的,一般情况下,我们推荐开发者在游戏启动时拉取一次当前登录用户的好友列表,然后缓存在本地,以后需要检查另外玩家是否为当前用户的好友时,直接从缓存中查询即可。如果担心好友数据变化,缓存没有得到及时更新,可以调用前面「响应好友变化通知」的方法,对好友数据更新进行监听,这样在绝大部分时候数据同步都是可以保证的。
## 4.云存档
### 构建云存档元数据
```c#
var gameSave = new TapGameSave
{
Name = "GameSave_Name",// 存档名称
Summary = "GameSave_Description", // 该字段会作为展示给用户的实际存档名
ModifiedAt = DateTime.Now.ToLocalTime(), // 原文件修改时间
PlayedTime = 1000L, // 游戏时长,单位 ms (非必填)
ProgressValue = 100, // 游戏进度 ,单位 int (非必填)
CoverFilePath = pic, // 游戏封面可以传入一个本地文件路径SDK 限制为 png/jpeg 格式
GameFilePath = dll // 存档源文件,可以传入一个本地文件路径
};
```
### 保存存档
保存存档时,会去检查当前`TDSUser`是否已经登录以及元数据。
同时 SDK 在上传时会去限制存档本身以及相关联的两个文件( Cover 以及 GameFile )的权限为当前用户本身。
```c#
await gameSave.Save();
```
### 查询当前用户的所有存档
```c#
var collection = await TapGameSave.GetCurrentUserGameSaves();
foreach(var gameSave in collection){
// 存档概览
var name = gameSave.Summary;
// 原文件修改时间
var modifiedAt = gameSave.ModifiedAt;
// 游戏时长
var playedTime = gameSave.PlayedTime;
// 游戏进度
var progressValue = gameSave.ProgressValue;
// 游戏封面
var coverFile = gameSave.CoverFile;
// 存档源文件
var gameFile = gameSave.GameFile;
// 源文件下载地址
var gameFileUrl = gameFile.Url;
}
```
### 查询当前用户存档
我们使用 `LCQuery` 来查询当前用户的云存档。
SDK 查询封装了一个限定方法用于查询当前`TDSUser`的云存档。
```c#
TDSUser user = await TDSUser.GetCurrent();
LCQuery<TapGameSave> gameSaveQuery = TapGameSave.GetQueryWithUser(user);
// 查询 Name 为 TDSUser_GameSave_Name 的云存档
gameSaveQuery.WhereEqualTo("name","TDSUser_GameSave_Name");
var collection = await gameSaveQuery.Find();
```

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 17ed6166c017a4fcda77ff618f2703db
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

8
Plugins.meta Normal file
View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: dc389bcfbbddc4d35a997cbc06799975
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,233 @@
{
"runtimeTarget": {
"name": ".NETStandard,Version=v2.0/",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETStandard,Version=v2.0": {},
".NETStandard,Version=v2.0/": {
"TapTap.Bootstrap/1.0.0": {
"dependencies": {
"NETStandard.Library": "2.0.3",
"TapTap.Common": "1.0.0",
"TapTap.Login": "1.0.0",
"Common": "1.0.0.0",
"LiveQuery": "1.0.0.0",
"Storage": "1.0.0.0",
"Storage.Unity": "1.0.0.0",
"UnityEngine": "0.0.0.0"
},
"runtime": {
"TapTap.Bootstrap.dll": {}
}
},
"Microsoft.NETCore.Platforms/1.1.0": {},
"NETStandard.Library/2.0.3": {
"dependencies": {
"Microsoft.NETCore.Platforms": "1.1.0"
}
},
"TapTap.Common/1.0.0": {
"runtime": {
"TapTap.Common.dll": {}
}
},
"TapTap.Login/1.0.0": {
"dependencies": {
"TapTap.Common": "1.0.0"
},
"runtime": {
"TapTap.Login.dll": {}
}
},
"Common/1.0.0.0": {
"runtime": {
"Common.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.0.0.0"
}
}
},
"LiveQuery/1.0.0.0": {
"runtime": {
"LiveQuery.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.0.0.0"
}
}
},
"Storage/1.0.0.0": {
"runtime": {
"Storage.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.0.0.0"
}
}
},
"Storage.Unity/1.0.0.0": {
"runtime": {
"Storage.Unity.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.0.0.0"
}
}
},
"UnityEngine/0.0.0.0": {
"runtime": {
"UnityEngine.dll": {
"assemblyVersion": "0.0.0.0",
"fileVersion": "0.0.0.0"
}
}
},
"LC.Newtonsoft.Json/11.0.0.0": {
"runtime": {
"LC.Newtonsoft.Json.dll": {
"assemblyVersion": "11.0.0.0",
"fileVersion": "11.0.1.0"
}
}
},
"Realtime/1.0.0.0": {
"runtime": {
"Realtime.dll": {
"assemblyVersion": "1.0.0.0",
"fileVersion": "1.0.0.0"
}
}
},
"LC.Google.Protobuf/3.14.0.0": {
"runtime": {
"LC.Google.Protobuf.dll": {
"assemblyVersion": "3.14.0.0",
"fileVersion": "3.14.0.0"
}
}
},
"System.Memory/4.0.1.1": {
"runtime": {
"System.Memory.dll": {
"assemblyVersion": "4.0.1.1",
"fileVersion": "4.6.27617.2"
}
}
},
"System.Runtime.CompilerServices.Unsafe/4.0.4.1": {
"runtime": {
"System.Runtime.CompilerServices.Unsafe.dll": {
"assemblyVersion": "4.0.4.1",
"fileVersion": "4.0.0.0"
}
}
},
"System.Buffers/4.0.2.0": {
"runtime": {
"System.Buffers.dll": {
"assemblyVersion": "4.0.2.0",
"fileVersion": "4.6.25519.3"
}
}
},
"System.Numerics.Vectors/4.1.3.0": {
"runtime": {
"System.Numerics.Vectors.dll": {
"assemblyVersion": "4.1.3.0",
"fileVersion": "4.6.25519.3"
}
}
}
}
},
"libraries": {
"TapTap.Bootstrap/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Microsoft.NETCore.Platforms/1.1.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==",
"path": "microsoft.netcore.platforms/1.1.0",
"hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512"
},
"NETStandard.Library/2.0.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
"path": "netstandard.library/2.0.3",
"hashPath": "netstandard.library.2.0.3.nupkg.sha512"
},
"TapTap.Common/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"TapTap.Login/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Common/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"LiveQuery/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"Storage/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"Storage.Unity/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"UnityEngine/0.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"LC.Newtonsoft.Json/11.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"Realtime/1.0.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"LC.Google.Protobuf/3.14.0.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"System.Memory/4.0.1.1": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"System.Runtime.CompilerServices.Unsafe/4.0.4.1": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"System.Buffers/4.0.2.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
},
"System.Numerics.Vectors/4.1.3.0": {
"type": "reference",
"serviceable": false,
"sha512": ""
}
}
}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 31cab863b627d4a509bd0f259bcf6a31
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 03acb073a9f88474581401ef1020c1c4
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b3d6c5154fb9d4319a2a32e6fde07f63
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

254
README.md Normal file
View File

@ -0,0 +1,254 @@
# [使用 TapTap.Bootstrap ](./Documentation/README.md)
## 使用前提
使用 TapTap.Bootstrap 前提是必须依赖以下库:
* [TapTap.Common](https://github.com/TapTap/TapCommon-Unity.git)
* [TapTap.Login](https://github.com/TapTap/TapLogin-Unity.git)
* [LeanCloud.Storage](https://github.com/leancloud/csharp-sdk)
* [LeanCloud.RealTime](https://github.com/leancloud/csharp-sdk)
## 命名空间
```c#
using TapTap.Bootstrap;
```
## 接口描述
## 1.初始化
TapBootstrap 会根据 TapConfig 中的 TapDBConfig 配置来进行 TapDB 的自动初始化。
### 开启 TapDB
```c#
var config = new TapConfig.Builder()
.ClientID("client_id")
.ClientToken("client_token")
.ServerURL("https://ikggdre2.lc-cn-n1-shared.com")
.RegionType(RegionType.CN)
.TapDBConfig(true,"channel","gameVersion",true)
.Builder();
```
### 关闭 TapDB
```c#
var config = new TapConfig.Builder()
.ClientID("client_id")
.ClientToken("client_token")
.ServerURL("https://ikggdre2.lc-cn-n1-shared.com")
.RegionType(RegionType.CN)
//# .TapDBConfig(false,null,null,false)
.EnableTapDB(false)
.Builder();
```
### 初始化
```c#
TapBootstrap.Init(config);
```
## 2.账户系统
> 登陆成功之后,都会得到一个 `TDSUser` 实例
### 使用 TapTap OAuth 授权结果直接登陆/注册账户系统
```c#
var tdsUser = await TDSUser.LoginWithTapTap();
```
### 游客登陆
```c#
var tdsUser = await TDSUser.LoginAnonymously();
```
### 使用第三方平台授权登录/注册账户
```c#
var tdsUser = await TDSUser.LoginWithAuthData(Dictionary<string, object> authData, string platform,
LCUserAuthDataLoginOption option = null);
```
### 绑定第三方平台授权
```c#
await TDSUser.AssociateAuthData(Dictionary<string, object> authData, string platform);
```
### 退出登陆
```c#
TDSUser.Logout();
```
## 3.好友系统
### 申请成为好友
```c#
TDSUser tom, jerry;
await tom.ApplyFriendship(jerry);
```
申请成功的回调中,我们会得到一个 LCFriendshipRequest 的实例,这个实例中包含了两个用户:
- sourceUser指请求的发起方上面的例子中就是 `tom`
- friend指请求的目的方上面的例子中就是 `jerry`
tom 也可以在申请好友的时候,添加更多的属性,例如 tom 希望加 jerry 为好友的时候,也设定一个名为 cat 的圈子,可以这样操作:
```cs
Dictionary<string, object> attrs = new Dictionary<string, object> {
{ "group", "cat" }
};
await tom.ApplyFriendship(jerry, attrs);
```
### 获取好友申请列表
好友申请有三种状态:
- `pending`,对方没有回应,还处于等待中。
- `accepted`,对方已经接受,现在双方成为好友。
- `declined`,对方已经拒绝。
好友请求创建之后默认是 `pending` 状态。
jerry 这里可以通过 `friendshipRequestQuery` 来查找不同状态的请求。例如 jerry 想看看新的好友请求,可以这样操作:
```cs
LCQuery<LCFriendshipRequest> query = jerry.GetFriendshipRequestQuery(LCFriendshipRequest.STATUS_PENDING, false, true);
ReadOnlyCollection<LCFriendshipRequest> reqs = await query.Find();
foreach (LCFriendshipRequest req in reqs) {
Console.WriteLine(req);
}
```
### 处理好友申请
jerry 对于新的好友请求,可以同意或者拒绝,也可以什么都不做,无视这些请求,甚至直接删除。这些操作我们都是支持的,请看下面的示例:
```cs
LCFriendshipRequest tomRequest, tuffyRequest, otherRequest;
await jerry.AcceptFriendshipRequest(tomRequest);
await jerry.DeclineFriendshipRequest(tuffyRequest);
await jerry.DeleteFriendshipRequest(otherRequest);
```
注意:
* 在 jerry 拒绝了 tom 的好友请求之后,如果 tom 再次请求成为 jerry 的好友tom 在执行 applyFriendshipInBackground 时会直接得到错误的应答,表明 jerry 不想和 ta 成为好友。
* jerry 同意了 tuffy 的好友请求之后,它们就成为了好友,之后两个人中任何一人再次调用 applyFriendshipInBackground 申请横位好友时,也会直接得到错误的应答,表明它们已经是好友无需再次申请。
* jerry 删除陌生人的好友请求后,对方还可以再次发起请求。
### 响应好友变化通知
TDS 好友模块支持客户端监听好友状态变化,在游戏中实时给玩家提示。好友状态变化的接口包括
```cs
public class FriendshipNotification {
public Action<LCFriendshipRequest> OnNewRequestComing { get; set; }
public Action<LCFriendshipRequest> OnRequestAccepted { get; set; }
public Action<LCFriendshipRequest> OnRequestDeclined { get; set; }
}
```
其中:
- onNewRequestComing 表示有其他人申请成为当前用户的好友,通过调用 `LCFriendshipRequest#getSourceUser()` 方法可以获得发起方用户信息。
- onRequestAccepted 表示当前用户的好友申请被对方通过,通过调用 `LCFriendshipRequest#getFriend()` 方法可以获得对方用户信息。
- onRequestDeclined 表示当前用户的好友申请被对方拒绝,通过调用 `LCFriendshipRequest#getFriend()` 方法可以获得对方用户信息。
开发者可以通过 `TDSUser#registerFriendshipNotification` 来注册通知接收器,通过调用 `TDSUser#unregisterFriendshipNotification` 来取消通知接收器。
### 获取好友列表
调用 `TDSUser#friendshipQuery()` 可以得到查询好友的 `LCQuery` 实例,之后调用 `LCQuery#findInBackground()` 方法就可以得到好友列表。示例如下:
```cs
LCQuery<LCObject> query = jerry.GetFirendshipQuery();
```
LCFriendship 里面会包含两个用户:
- `LCFriendship#getLCUser(LCFriendship.ATTR_USER)` 得到的是 jerry 自己;
- `LCFriendship#getLCUser(LCFriendship.ATTR_FOLLOWEE)` 得到的就是另一方的用户信息。
### 删除好友
成为好友关系的两个用户,之后也可以单方面删除好友。例如 jerry 不想再和 tom 成为好友,那只需要在自己的好友列表中删除包含 tom 的那条 LCFriendship 记录即可:
```cs
await friendship.Delete();
```
### 查询好友关系
我们使用 LCQuery 可以单独查询两个用户是否为好友关系。
```cs
LCQuery<LCObject> query = jerry.GetFirendshipQuery();
query.whereEqualTo("followee", tom);
int count = await query.Count();
if (count > 0) {
// tom is a friend of jerry.
} else {
// tom isn't a friend of jerry.
}
```
这一查询是通过网络发送到服务端执行的,一般情况下,我们推荐开发者在游戏启动时拉取一次当前登录用户的好友列表,然后缓存在本地,以后需要检查另外玩家是否为当前用户的好友时,直接从缓存中查询即可。如果担心好友数据变化,缓存没有得到及时更新,可以调用前面「响应好友变化通知」的方法,对好友数据更新进行监听,这样在绝大部分时候数据同步都是可以保证的。
## 4.云存档
### 构建云存档元数据
```c#
var gameSave = new TapGameSave
{
Name = "GameSave_Name",// 存档名称
Summary = "GameSave_Description", // 该字段会作为展示给用户的实际存档名
ModifiedAt = DateTime.Now.ToLocalTime(), // 原文件修改时间
PlayedTime = 1000L, // 游戏时长,单位 ms (非必填)
ProgressValue = 100, // 游戏进度 ,单位 int (非必填)
CoverFilePath = pic, // 游戏封面可以传入一个本地文件路径SDK 限制为 png/jpeg 格式
GameFilePath = dll // 存档源文件,可以传入一个本地文件路径
};
```
### 保存存档
保存存档时,会去检查当前`TDSUser`是否已经登录以及元数据。
同时 SDK 在上传时会去限制存档本身以及相关联的两个文件( Cover 以及 GameFile )的权限为当前用户本身。
```c#
await gameSave.Save();
```
### 查询当前用户的所有存档
```c#
var collection = await TapGameSave.GetCurrentUserGameSaves();
foreach(var gameSave in collection){
// 存档概览
var name = gameSave.Summary;
// 原文件修改时间
var modifiedAt = gameSave.ModifiedAt;
// 游戏时长
var playedTime = gameSave.PlayedTime;
// 游戏进度
var progressValue = gameSave.ProgressValue;
// 游戏封面
var coverFile = gameSave.CoverFile;
// 存档源文件
var gameFile = gameSave.GameFile;
// 源文件下载地址
var gameFileUrl = gameFile.Url;
}
```
### 查询云存档
云存档只能查询当前用户的所有存档,需要查询该用户的特定存档时,可以增加相应过滤,可参考 [查询条件](https://developer.taptap.com/docs/sdk/storage/guide/objc/#%E6%9F%A5%E8%AF%A2%E6%9D%A1%E4%BB%B6)
```c#
TDSUser user = await TDSUser.GetCurrent();
LCQuery<TapGameSave> gameSaveQuery = TapGameSave.GetQueryWithUser(user);
// 查询 Name 为 TDSUser_GameSave_Name 的云存档
gameSaveQuery.WhereEqualTo("name","TDSUser_GameSave_Name");
var collection = await gameSaveQuery.Find();
```

3
README.md.meta Normal file
View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: c5330aab2c6a41699a1601f1af6b27d9
timeCreated: 1616755935

0
VERSIONNOTE.md Normal file
View File

7
VERSIONNOTE.md.meta Normal file
View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d5391b17003874fb2afc3e309a3f63ef
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

14
package.json Normal file
View File

@ -0,0 +1,14 @@
{
"name": "com.taptap.tds.bootstrap",
"displayName": "TapTap Bootstrap",
"description": "TapTap Develop Service",
"version": "3.18.2-alpha1",
"unity": "2018.3",
"license": "MIT",
"dependencies": {
"com.taptap.tds.common": "https://github.com/TapTap/TapCommon-Unity.git#3.18.2-alpha1",
"com.taptap.tds.login": "https://github.com/TapTap/TapLogin-Unity.git#3.18.2-alpha1",
"com.leancloud.realtime": "https://github.com/leancloud/csharp-sdk-upm.git#realtime-0.10.14",
"com.leancloud.storage": "https://github.com/leancloud/csharp-sdk-upm.git#storage-0.10.14"
}
}

7
package.json.meta Normal file
View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: e618b9375caf846708cffea428908521
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: