From ea5b96507de28bd94c0946ccfd49fa66367770ce Mon Sep 17 00:00:00 2001 From: "CORE-FOLDCC\\Core" <1813547935@qq.com> Date: Fri, 10 Apr 2026 22:38:28 +0800 Subject: [PATCH] Localize sample UI and document release conventions --- .../Announcement/BriskAnnouncementsModule.cs | 9 + .../Runtime/Archive/BriskArchiveModule.cs | 15 + .../BriskSdk/Runtime/Auth/BriskAuthModule.cs | 12 + .../Runtime/Config/BriskConfigModule.cs | 9 + Assets/BriskSdk/Runtime/Core/Brisk.cs | 76 +++++ Assets/BriskSdk/Runtime/Core/BriskOptions.cs | 33 ++ .../Runtime/Core/IBriskErrorPresenter.cs | 9 + .../BriskSdk/Runtime/Core/IBriskTokenStore.cs | 12 + .../Leaderboard/BriskLeaderboardModule.cs | 24 ++ .../Runtime/Models/BriskConfigCurrent.cs | 9 + .../BriskSdk/Runtime/Models/BriskIdentity.cs | 15 + .../Runtime/Models/BriskLoginResult.cs | 27 ++ .../BriskSdk/Runtime/Models/BriskPlayerMe.cs | 24 ++ .../BriskSdk/Runtime/Models/BriskProfile.cs | 12 + .../Runtime/Player/BriskPlayerModule.cs | 6 + .../Runtime/Space/BriskSpaceModule.cs | 33 ++ .../QuickStart/BriskQuickStartSample.cs | 298 +++++++++--------- Assets/Scenes/BriskQuickStartScene.unity | 6 +- Brisk Package 发布流程.md | 58 ++++ .../Announcement/BriskAnnouncementsModule.cs | 9 + .../Runtime/Archive/BriskArchiveModule.cs | 15 + .../Runtime/Auth/BriskAuthModule.cs | 12 + .../Runtime/Config/BriskConfigModule.cs | 9 + .../Runtime/Core/Brisk.cs | 76 +++++ .../Runtime/Core/BriskOptions.cs | 33 ++ .../Runtime/Core/IBriskErrorPresenter.cs | 9 + .../Runtime/Core/IBriskTokenStore.cs | 12 + .../Leaderboard/BriskLeaderboardModule.cs | 24 ++ .../Runtime/Models/BriskConfigCurrent.cs | 9 + .../Runtime/Models/BriskIdentity.cs | 15 + .../Runtime/Models/BriskLoginResult.cs | 27 ++ .../Runtime/Models/BriskPlayerMe.cs | 24 ++ .../Runtime/Models/BriskProfile.cs | 12 + .../Runtime/Player/BriskPlayerModule.cs | 6 + .../Runtime/Space/BriskSpaceModule.cs | 33 ++ .../QuickStart/BriskQuickStartSample.cs | 298 +++++++++--------- .../QuickStart/BriskQuickStartScene.unity | 6 +- 37 files changed, 1012 insertions(+), 304 deletions(-) diff --git a/Assets/BriskSdk/Runtime/Announcement/BriskAnnouncementsModule.cs b/Assets/BriskSdk/Runtime/Announcement/BriskAnnouncementsModule.cs index ea46be0..3e296f3 100644 --- a/Assets/BriskSdk/Runtime/Announcement/BriskAnnouncementsModule.cs +++ b/Assets/BriskSdk/Runtime/Announcement/BriskAnnouncementsModule.cs @@ -2,9 +2,15 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +/// +/// 公告模块。 +/// public sealed class BriskAnnouncementsModule : BriskModuleBase { + /// + /// 获取公告列表。 + /// public async Task> GetListAsync() { return await ExecuteAsync(async context => @@ -14,6 +20,9 @@ public sealed class BriskAnnouncementsModule }); } + /// + /// 标记指定公告为已读。 + /// public async Task MarkReadAsync(long id) { RequirePositive(id, nameof(id), "Announcement id must be greater than 0."); diff --git a/Assets/BriskSdk/Runtime/Archive/BriskArchiveModule.cs b/Assets/BriskSdk/Runtime/Archive/BriskArchiveModule.cs index 3e6d0cd..de9ed05 100644 --- a/Assets/BriskSdk/Runtime/Archive/BriskArchiveModule.cs +++ b/Assets/BriskSdk/Runtime/Archive/BriskArchiveModule.cs @@ -5,9 +5,15 @@ using System.Text; using System.Threading.Tasks; using UnityEngine.Networking; +/// +/// 云存档模块。 +/// public sealed class BriskArchiveModule : BriskModuleBase { + /// + /// 获取当前账号的存档槽位列表。 + /// public async Task> GetSlotsAsync() { return await ExecuteAsync(async context => @@ -17,6 +23,9 @@ public sealed class BriskArchiveModule }); } + /// + /// 获取指定槽位的元信息。 + /// public async Task GetMetaAsync(int slotNo) { ValidateSlotNo(slotNo); @@ -28,6 +37,9 @@ public sealed class BriskArchiveModule }); } + /// + /// 上传指定槽位的二进制存档。 + /// public async Task UploadAsync(int slotNo, byte[] bytes, int? baseVersion = null, string checksum = null) { ValidateSlotNo(slotNo); @@ -51,6 +63,9 @@ public sealed class BriskArchiveModule }); } + /// + /// 下载指定槽位的二进制存档。 + /// public async Task DownloadAsync(int slotNo) { ValidateSlotNo(slotNo); diff --git a/Assets/BriskSdk/Runtime/Auth/BriskAuthModule.cs b/Assets/BriskSdk/Runtime/Auth/BriskAuthModule.cs index 275d4ba..6219f6a 100644 --- a/Assets/BriskSdk/Runtime/Auth/BriskAuthModule.cs +++ b/Assets/BriskSdk/Runtime/Auth/BriskAuthModule.cs @@ -2,9 +2,15 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +/// +/// Brisk 认证模块。 +/// public sealed class BriskAuthModule : BriskModuleBase { + /// + /// 通过稳定的第三方用户 ID 换取 Brisk 登录态。 + /// public async Task LoginWithUserIdAsync(string loginProvider, string loginUserId, BriskProfile profile = null) { RequireNotEmpty(loginProvider, nameof(loginProvider)); @@ -13,6 +19,9 @@ public sealed class BriskAuthModule return await LoginInternalAsync(CreateLoginBody(loginProvider, profile, loginUserId, null), loginProvider, loginUserId); } + /// + /// 通过第三方返回的 code 换取 Brisk 登录态。 + /// public async Task LoginWithCodeAsync(string loginProvider, string code, BriskProfile profile = null) { RequireNotEmpty(loginProvider, nameof(loginProvider)); @@ -21,6 +30,9 @@ public sealed class BriskAuthModule return await LoginInternalAsync(CreateLoginBody(loginProvider, profile, null, code), loginProvider, null); } + /// + /// 登出当前账号并清理本地会话。 + /// public async Task LogoutAsync() { var context = GetContext(); diff --git a/Assets/BriskSdk/Runtime/Config/BriskConfigModule.cs b/Assets/BriskSdk/Runtime/Config/BriskConfigModule.cs index 75e71a8..b9f999b 100644 --- a/Assets/BriskSdk/Runtime/Config/BriskConfigModule.cs +++ b/Assets/BriskSdk/Runtime/Config/BriskConfigModule.cs @@ -2,9 +2,15 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +/// +/// 动态配置模块。 +/// public sealed class BriskConfigModule : BriskModuleBase { + /// + /// 获取当前客户端命中的动态配置。 + /// public async Task GetCurrentAsync() { return await ExecutePublicAsync(async context => @@ -14,6 +20,9 @@ public sealed class BriskConfigModule }); } + /// + /// 刷新并重新获取动态配置。 + /// public Task RefreshAsync() { return GetCurrentAsync(); diff --git a/Assets/BriskSdk/Runtime/Core/Brisk.cs b/Assets/BriskSdk/Runtime/Core/Brisk.cs index 4dd02f5..ff77830 100644 --- a/Assets/BriskSdk/Runtime/Core/Brisk.cs +++ b/Assets/BriskSdk/Runtime/Core/Brisk.cs @@ -2,6 +2,10 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +/// +/// Brisk SDK 的静态总入口。 +/// 初始化完成后,开发者可以通过 Brisk.AuthBrisk.Leaderboard 等模块直接访问能力。 +/// public static class Brisk { private static BriskContext s_context; @@ -17,40 +21,101 @@ public static class Brisk Space = new BriskSpaceModule(); } + /// + /// SDK 初始化完成后触发。 + /// public static event Action OnInitialized; + /// + /// 登录成功并保存会话后触发。 + /// public static event Action OnLoggedIn; + /// + /// 主动登出并清理本地会话后触发。 + /// public static event Action OnLoggedOut; + /// + /// 发生维护、封禁、强更等严重阻断错误时触发。 + /// public static event Action OnBlockingError; + /// + /// 登录态失效并清空本地会话时触发。 + /// public static event Action OnAuthExpired; + /// + /// 认证模块入口。 + /// public static BriskAuthModule Auth { get; } + /// + /// 玩家模块入口。 + /// public static BriskPlayerModule Player { get; } + /// + /// 动态配置模块入口。 + /// public static BriskConfigModule Config { get; } + /// + /// 公告模块入口。 + /// public static BriskAnnouncementsModule Announcements { get; } + /// + /// 排行榜模块入口。 + /// public static BriskLeaderboardModule Leaderboard { get; } + /// + /// 云存档模块入口。 + /// public static BriskArchiveModule Archive { get; } + /// + /// 玩家空间模块入口。 + /// public static BriskSpaceModule Space { get; } + /// + /// 当前 SDK 是否已完成初始化。 + /// public static bool IsInitialized => s_context != null; + /// + /// 当前是否存在可用登录态。 + /// public static bool IsLoggedIn => s_context != null && s_context.Session.HasAccessToken; + /// + /// 当前访问令牌。 + /// public static string AccessToken => s_context != null ? s_context.Session.AccessToken : null; + /// + /// 当前玩家 ID。 + /// public static string PlayerId => s_context != null ? s_context.Session.PlayerId : null; + /// + /// 当前登录身份摘要。 + /// public static BriskIdentity Identity => s_context != null ? s_context.Session.Identity : null; + /// + /// 当前初始化选项。 + /// public static BriskOptions Options => s_context != null ? s_context.Options : null; + /// + /// 初始化阶段获取到的 bootstrap 结果。 + /// public static BriskBootstrapResult Bootstrap => s_context != null ? s_context.Bootstrap : null; + /// + /// 初始化 SDK,并执行 bootstrap 与本地会话恢复。 + /// + /// 初始化选项。 public static async Task InitializeAsync(BriskOptions options) { if (options == null) @@ -79,16 +144,27 @@ public static class Brisk } } + /// + /// 关闭 SDK 并清空当前上下文。 + /// public static void Shutdown() { s_context = null; } + /// + /// 设置严重错误的展示器。 + /// + /// 自定义错误展示器;传入 null 时恢复默认展示器。 public static void SetErrorPresenter(IBriskErrorPresenter presenter) { GetRequiredContext().ErrorPresenter = presenter ?? BriskDefaultErrorPresenter.Instance; } + /// + /// 设置阻断错误确认后的退出回调。 + /// + /// 项目方自定义退出逻辑。 public static void SetExitHandler(Action exitHandler) { GetRequiredContext().ExitHandler = exitHandler; diff --git a/Assets/BriskSdk/Runtime/Core/BriskOptions.cs b/Assets/BriskSdk/Runtime/Core/BriskOptions.cs index a54deae..6bc6211 100644 --- a/Assets/BriskSdk/Runtime/Core/BriskOptions.cs +++ b/Assets/BriskSdk/Runtime/Core/BriskOptions.cs @@ -1,17 +1,50 @@ using System; +/// +/// Brisk SDK 初始化参数。 +/// public sealed class BriskOptions { + /// + /// 服务端基础地址。可以传主机地址,SDK 会自动补上 /api。 + /// public string BaseUrl; + /// + /// 项目标识。 + /// public string GameKey; + /// + /// 客户端版本号。 + /// public string ClientVersion; + /// + /// 设备标识。 + /// public string DeviceId; + /// + /// 是否启用调试日志。 + /// public bool EnableLog; + /// + /// 初始化时是否主动校验本地会话有效性。 + /// public bool ValidateSessionOnInitialize = true; + /// + /// 自定义登录态持久化实现。 + /// public IBriskTokenStore TokenStore; + /// + /// 自定义严重错误展示器。 + /// public IBriskErrorPresenter ErrorPresenter; + /// + /// 阻断错误确认后的退出处理逻辑。 + /// public Action ExitHandler; + /// + /// 校验并规范化初始化参数。 + /// public void Validate() { if (string.IsNullOrWhiteSpace(BaseUrl)) diff --git a/Assets/BriskSdk/Runtime/Core/IBriskErrorPresenter.cs b/Assets/BriskSdk/Runtime/Core/IBriskErrorPresenter.cs index 8dddfe3..4f85ea1 100644 --- a/Assets/BriskSdk/Runtime/Core/IBriskErrorPresenter.cs +++ b/Assets/BriskSdk/Runtime/Core/IBriskErrorPresenter.cs @@ -1,6 +1,15 @@ +/// +/// 自定义严重错误展示接口。 +/// public interface IBriskErrorPresenter { + /// + /// 展示维护、封禁、强更等阻断错误。 + /// void ShowBlockingError(BriskBlockingException exception); + /// + /// 展示登录态失效提示。 + /// void ShowAuthExpired(BriskAuthExpiredException exception); } diff --git a/Assets/BriskSdk/Runtime/Core/IBriskTokenStore.cs b/Assets/BriskSdk/Runtime/Core/IBriskTokenStore.cs index 9b452ff..d6127f6 100644 --- a/Assets/BriskSdk/Runtime/Core/IBriskTokenStore.cs +++ b/Assets/BriskSdk/Runtime/Core/IBriskTokenStore.cs @@ -1,10 +1,22 @@ using System.Threading.Tasks; +/// +/// 自定义登录态持久化接口。 +/// public interface IBriskTokenStore { + /// + /// 保存当前登录会话。 + /// Task SaveAsync(BriskStoredSession session); + /// + /// 读取本地保存的登录会话。 + /// Task LoadAsync(); + /// + /// 清空本地保存的登录会话。 + /// Task ClearAsync(); } diff --git a/Assets/BriskSdk/Runtime/Leaderboard/BriskLeaderboardModule.cs b/Assets/BriskSdk/Runtime/Leaderboard/BriskLeaderboardModule.cs index 6f8d171..7112196 100644 --- a/Assets/BriskSdk/Runtime/Leaderboard/BriskLeaderboardModule.cs +++ b/Assets/BriskSdk/Runtime/Leaderboard/BriskLeaderboardModule.cs @@ -2,9 +2,15 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +/// +/// 排行榜模块。 +/// public sealed class BriskLeaderboardModule : BriskModuleBase { + /// + /// 获取排行榜 Top 列表。 + /// public async Task> GetTopAsync(string rankKey, int limit = 20) { ValidateRankKey(rankKey); @@ -19,6 +25,9 @@ public sealed class BriskLeaderboardModule }); } + /// + /// 获取当前玩家在排行榜中的信息。 + /// public async Task GetMeAsync(string rankKey) { ValidateRankKey(rankKey); @@ -30,6 +39,9 @@ public sealed class BriskLeaderboardModule }); } + /// + /// 获取当前玩家附近的排名区间。 + /// public async Task> GetAroundMeAsync(string rankKey, int range = 10) { ValidateRankKey(rankKey); @@ -44,6 +56,9 @@ public sealed class BriskLeaderboardModule }); } + /// + /// 提交当前玩家分数。 + /// public async Task SubmitScoreAsync(string rankKey, long score) { ValidateRankKey(rankKey); @@ -57,6 +72,9 @@ public sealed class BriskLeaderboardModule }); } + /// + /// 获取当前赛季信息。 + /// public async Task GetCurrentSeasonAsync(string rankKey) { ValidateRankKey(rankKey); @@ -68,6 +86,9 @@ public sealed class BriskLeaderboardModule }); } + /// + /// 获取赛季历史列表。 + /// public async Task> GetSeasonHistoryAsync(string rankKey, int limit = 20) { ValidateRankKey(rankKey); @@ -82,6 +103,9 @@ public sealed class BriskLeaderboardModule }); } + /// + /// 获取指定历史赛季的排行榜详情。 + /// public async Task> GetSeasonHistoryDetailAsync(string rankKey, string seasonId, int limit = 20) { ValidateRankKey(rankKey); diff --git a/Assets/BriskSdk/Runtime/Models/BriskConfigCurrent.cs b/Assets/BriskSdk/Runtime/Models/BriskConfigCurrent.cs index 9f5e264..221c5f5 100644 --- a/Assets/BriskSdk/Runtime/Models/BriskConfigCurrent.cs +++ b/Assets/BriskSdk/Runtime/Models/BriskConfigCurrent.cs @@ -1,7 +1,16 @@ using System.Collections.Generic; +/// +/// 当前客户端命中的动态配置结果。 +/// public sealed class BriskConfigCurrent { + /// + /// 功能开关集合。 + /// public Dictionary FeatureFlags; + /// + /// 动态配置集合。 + /// public Dictionary DynamicConfig; } diff --git a/Assets/BriskSdk/Runtime/Models/BriskIdentity.cs b/Assets/BriskSdk/Runtime/Models/BriskIdentity.cs index fc2525a..bd9be7a 100644 --- a/Assets/BriskSdk/Runtime/Models/BriskIdentity.cs +++ b/Assets/BriskSdk/Runtime/Models/BriskIdentity.cs @@ -1,7 +1,22 @@ +/// +/// 当前登录身份摘要。 +/// public sealed class BriskIdentity { + /// + /// 登录提供方。 + /// public string LoginProvider; + /// + /// 登录用户 ID。 + /// public string LoginUserId; + /// + /// 玩家 ID。 + /// public string PlayerId; + /// + /// 项目账号 ID。 + /// public string ProjectAccountId; } diff --git a/Assets/BriskSdk/Runtime/Models/BriskLoginResult.cs b/Assets/BriskSdk/Runtime/Models/BriskLoginResult.cs index 536112c..950c40c 100644 --- a/Assets/BriskSdk/Runtime/Models/BriskLoginResult.cs +++ b/Assets/BriskSdk/Runtime/Models/BriskLoginResult.cs @@ -1,11 +1,38 @@ +/// +/// 登录成功后的返回结果。 +/// public sealed class BriskLoginResult { + /// + /// Brisk 访问令牌。 + /// public string AccessToken; + /// + /// 令牌有效时长,单位秒。 + /// public int ExpiresIn; + /// + /// 玩家 ID。 + /// public string PlayerId; + /// + /// 项目账号 ID。 + /// public string ProjectAccountId; + /// + /// 登录提供方。 + /// public string LoginProvider; + /// + /// 登录用户 ID。 + /// public string LoginUserId; + /// + /// 是否为新玩家。 + /// public bool IsNewPlayer; + /// + /// 玩家资料。 + /// public BriskProfile Profile; } diff --git a/Assets/BriskSdk/Runtime/Models/BriskPlayerMe.cs b/Assets/BriskSdk/Runtime/Models/BriskPlayerMe.cs index 5c929c2..5bc0580 100644 --- a/Assets/BriskSdk/Runtime/Models/BriskPlayerMe.cs +++ b/Assets/BriskSdk/Runtime/Models/BriskPlayerMe.cs @@ -1,10 +1,34 @@ +/// +/// 当前玩家资料。 +/// public sealed class BriskPlayerMe { + /// + /// 玩家 ID。 + /// public string PlayerId; + /// + /// 项目账号 ID。 + /// public string ProjectAccountId; + /// + /// 登录提供方。 + /// public string LoginProvider; + /// + /// 登录用户 ID。 + /// public string LoginUserId; + /// + /// 昵称。 + /// public string Nickname; + /// + /// 头像地址。 + /// public string AvatarUrl; + /// + /// 扩展资料。 + /// public object ProfileJson; } diff --git a/Assets/BriskSdk/Runtime/Models/BriskProfile.cs b/Assets/BriskSdk/Runtime/Models/BriskProfile.cs index 7acce66..98fc821 100644 --- a/Assets/BriskSdk/Runtime/Models/BriskProfile.cs +++ b/Assets/BriskSdk/Runtime/Models/BriskProfile.cs @@ -1,6 +1,18 @@ +/// +/// 登录时可选上传的玩家资料。 +/// public sealed class BriskProfile { + /// + /// 玩家昵称。 + /// public string Nickname; + /// + /// 玩家头像地址。 + /// public string AvatarUrl; + /// + /// 额外扩展资料。 + /// public object ProfileJson; } diff --git a/Assets/BriskSdk/Runtime/Player/BriskPlayerModule.cs b/Assets/BriskSdk/Runtime/Player/BriskPlayerModule.cs index 6fdde7a..9c39493 100644 --- a/Assets/BriskSdk/Runtime/Player/BriskPlayerModule.cs +++ b/Assets/BriskSdk/Runtime/Player/BriskPlayerModule.cs @@ -1,9 +1,15 @@ using System; using System.Threading.Tasks; +/// +/// 玩家模块。 +/// public sealed class BriskPlayerModule : BriskModuleBase { + /// + /// 获取当前登录玩家信息。 + /// public async Task GetMeAsync() { return await ExecuteAsync(async context => diff --git a/Assets/BriskSdk/Runtime/Space/BriskSpaceModule.cs b/Assets/BriskSdk/Runtime/Space/BriskSpaceModule.cs index 18f4266..ebd61a8 100644 --- a/Assets/BriskSdk/Runtime/Space/BriskSpaceModule.cs +++ b/Assets/BriskSdk/Runtime/Space/BriskSpaceModule.cs @@ -2,9 +2,15 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +/// +/// 玩家空间模块。 +/// public sealed class BriskSpaceModule : BriskModuleBase { + /// + /// 按玩家 ID 获取空间数据。 + /// public async Task GetByPlayerIdAsync(string playerId) { ValidatePlayerId(playerId); @@ -16,6 +22,9 @@ public sealed class BriskSpaceModule }); } + /// + /// 按登录身份获取空间数据。 + /// public async Task GetByLoginIdentityAsync(string loginProvider, string loginUserId) { ValidateLoginIdentity(loginProvider, loginUserId); @@ -27,6 +36,9 @@ public sealed class BriskSpaceModule }); } + /// + /// 按玩家 ID 获取空间统计。 + /// public async Task GetStatsByPlayerIdAsync(string playerId) { ValidatePlayerId(playerId); @@ -38,6 +50,9 @@ public sealed class BriskSpaceModule }); } + /// + /// 按登录身份获取空间统计。 + /// public async Task GetStatsByLoginIdentityAsync(string loginProvider, string loginUserId) { ValidateLoginIdentity(loginProvider, loginUserId); @@ -49,6 +64,9 @@ public sealed class BriskSpaceModule }); } + /// + /// 按玩家 ID 点赞空间。 + /// public async Task LikeByPlayerIdAsync(string playerId) { ValidatePlayerId(playerId); @@ -58,6 +76,9 @@ public sealed class BriskSpaceModule }); } + /// + /// 按玩家 ID 取消点赞空间。 + /// public async Task UnlikeByPlayerIdAsync(string playerId) { ValidatePlayerId(playerId); @@ -67,6 +88,9 @@ public sealed class BriskSpaceModule }); } + /// + /// 按登录身份点赞空间。 + /// public async Task LikeByLoginIdentityAsync(string loginProvider, string loginUserId) { ValidateLoginIdentity(loginProvider, loginUserId); @@ -76,6 +100,9 @@ public sealed class BriskSpaceModule }); } + /// + /// 按登录身份取消点赞空间。 + /// public async Task UnlikeByLoginIdentityAsync(string loginProvider, string loginUserId) { ValidateLoginIdentity(loginProvider, loginUserId); @@ -85,6 +112,9 @@ public sealed class BriskSpaceModule }); } + /// + /// 更新当前玩家自己的空间内容。 + /// public async Task UpdateMyAsync(object payload) { RequireNotNull(payload, nameof(payload)); @@ -98,6 +128,9 @@ public sealed class BriskSpaceModule }); } + /// + /// 获取我的访客列表。 + /// public async Task> GetMyVisitsAsync() { return await ExecuteAsync(async context => diff --git a/Assets/BriskSdk/Samples/QuickStart/BriskQuickStartSample.cs b/Assets/BriskSdk/Samples/QuickStart/BriskQuickStartSample.cs index 76f731d..b67477c 100644 --- a/Assets/BriskSdk/Samples/QuickStart/BriskQuickStartSample.cs +++ b/Assets/BriskSdk/Samples/QuickStart/BriskQuickStartSample.cs @@ -8,21 +8,21 @@ using UnityEngine; public sealed class BriskQuickStartSample : MonoBehaviour { - [Header("Init")] + [Header("初始化")] public string BaseUrl = "https://brisk.lightyears.ltd"; public string GameKey = "demo-game"; public string ClientVersion = "1.0.0"; public string DeviceId = "editor-device"; public bool ValidateSessionOnInitialize = true; - [Header("Login")] + [Header("登录")] public string LoginProvider = "tap"; public string LoginUserId = "tap_user_10001"; public string LoginCode = string.Empty; - public string Nickname = "Unity Sample User"; + public string Nickname = "Unity示例玩家"; public string AvatarUrl = string.Empty; - [Header("Leaderboard")] + [Header("排行榜")] public string RankKey = "season-score"; public string SubmitScoreValue = "128"; public string LeaderboardLimit = "10"; @@ -30,23 +30,23 @@ public sealed class BriskQuickStartSample : MonoBehaviour public string SeasonId = string.Empty; public string SeasonHistoryLimit = "20"; - [Header("Archive")] + [Header("云存档")] public string ArchiveSlotNo = "1"; public string ArchiveBaseVersion = string.Empty; [TextArea(3, 6)] - public string ArchiveContent = "{\n \"save\": 1,\n \"coins\": 128,\n \"hero\": \"mage\"\n}"; + public string ArchiveContent = "{\n \"save\": 1,\n \"coins\": 128,\n \"hero\": \"mage\",\n \"title\": \"中文测试存档\"\n}"; - [Header("Announcements")] + [Header("公告")] public string AnnouncementId = string.Empty; - [Header("Space")] + [Header("玩家空间")] public string SpacePlayerId = string.Empty; public string SpaceLoginProvider = "tap"; public string SpaceLoginUserId = "tap_user_10001"; [TextArea(3, 6)] - public string SpacePayloadText = "{\n \"mood\": \"ready\",\n \"title\": \"hello brisk\"\n}"; + public string SpacePayloadText = "{\n \"mood\": \"ready\",\n \"title\": \"你好 Brisk\",\n \"desc\": \"这是中文测试空间数据\"\n}"; - [Header("Demo")] + [Header("演示")] public bool AutoRunOnStart; private readonly List _eventLogs = new List(); @@ -56,8 +56,8 @@ public sealed class BriskQuickStartSample : MonoBehaviour private Vector2 _logScroll; private bool _isBusy; private string _busyAction = string.Empty; - private string _statusText = "Ready."; - private string _resultText = "No request yet."; + private string _statusText = "就绪"; + private string _resultText = "尚未执行请求。"; private string _lastErrorText = string.Empty; private IReadOnlyList _announcementCache = Array.Empty(); private IReadOnlyList _seasonHistoryCache = Array.Empty(); @@ -84,14 +84,14 @@ public sealed class BriskQuickStartSample : MonoBehaviour { if (AutoRunOnStart) { - RunAction("Auto Smoke Run", RunSmokeFlowAsync); + RunAction("自动冒烟流程", RunSmokeFlowAsync); } } - [ContextMenu("Run Brisk Sample")] + [ContextMenu("运行 Brisk 示例")] public void RunFromContextMenu() { - RunAction("Context Smoke Run", RunSmokeFlowAsync); + RunAction("右键菜单冒烟流程", RunSmokeFlowAsync); } private void OnGUI() @@ -117,40 +117,40 @@ public sealed class BriskQuickStartSample : MonoBehaviour private void DrawHeader() { - GUILayout.Label("Brisk IMGUI Sample", GUI.skin.box); - GUILayout.Label("This sample is designed for full SDK flow testing inside a single scene.", GUI.skin.label); + GUILayout.Label("Brisk IMGUI 测试面板", GUI.skin.box); + GUILayout.Label("这个场景用于在一个页面内测试 SDK 的完整流程。", GUI.skin.label); } private void DrawStatusPanel() { - BeginSection("Runtime Status"); - DrawReadOnlyRow("Initialized", Brisk.IsInitialized ? "Yes" : "No"); - DrawReadOnlyRow("Logged In", Brisk.IsLoggedIn ? "Yes" : "No"); + BeginSection("运行状态"); + DrawReadOnlyRow("已初始化", Brisk.IsInitialized ? "是" : "否"); + DrawReadOnlyRow("已登录", Brisk.IsLoggedIn ? "是" : "否"); DrawReadOnlyRow("PlayerId", Brisk.PlayerId); - DrawReadOnlyRow("Identity", Brisk.Identity == null ? string.Empty : Brisk.Identity.LoginProvider + " / " + Brisk.Identity.LoginUserId); - DrawReadOnlyRow("Current Action", _isBusy ? _busyAction : "Idle"); - DrawReadOnlyRow("Status", _statusText); + DrawReadOnlyRow("当前身份", Brisk.Identity == null ? string.Empty : Brisk.Identity.LoginProvider + " / " + Brisk.Identity.LoginUserId); + DrawReadOnlyRow("当前动作", _isBusy ? _busyAction : "空闲"); + DrawReadOnlyRow("状态", _statusText); GUILayout.BeginHorizontal(); - DrawButton("Run Smoke Flow", RunSmokeFlowAsync); - DrawButton("Show Bootstrap Cache", () => + DrawButton("执行冒烟流程", RunSmokeFlowAsync); + DrawButton("查看 Bootstrap 缓存", () => { - SetResult("Bootstrap Cache", Brisk.Bootstrap); + SetResult("Bootstrap 缓存", Brisk.Bootstrap); return Task.CompletedTask; }, Brisk.IsInitialized); - DrawButton("Shutdown SDK", () => + DrawButton("关闭 SDK", () => { Brisk.Shutdown(); - Log("SDK shutdown."); - _statusText = "SDK shutdown."; + Log("SDK 已关闭。"); + _statusText = "SDK 已关闭"; return Task.CompletedTask; }); - DrawButton("Clear Output", () => + DrawButton("清空输出", () => { - _resultText = "Output cleared."; + _resultText = "输出已清空。"; _lastErrorText = string.Empty; _eventLogs.Clear(); - _statusText = "Output cleared."; + _statusText = "输出已清空"; return Task.CompletedTask; }); GUILayout.EndHorizontal(); @@ -159,47 +159,47 @@ public sealed class BriskQuickStartSample : MonoBehaviour private void DrawInitSection() { - BeginSection("Initialize"); - BaseUrl = DrawEditableRow("Base Url", BaseUrl); - GameKey = DrawEditableRow("Game Key", GameKey); - ClientVersion = DrawEditableRow("Client Version", ClientVersion); - DeviceId = DrawEditableRow("Device Id", DeviceId); - ValidateSessionOnInitialize = DrawToggleRow("Validate Session On Init", ValidateSessionOnInitialize); + BeginSection("初始化"); + BaseUrl = DrawEditableRow("服务地址", BaseUrl); + GameKey = DrawEditableRow("游戏 Key", GameKey); + ClientVersion = DrawEditableRow("客户端版本", ClientVersion); + DeviceId = DrawEditableRow("设备标识", DeviceId); + ValidateSessionOnInitialize = DrawToggleRow("初始化时校验旧会话", ValidateSessionOnInitialize); GUILayout.BeginHorizontal(); - DrawButton("Initialize", InitializeAsync); - DrawButton("Reinitialize", ReinitializeAsync); + DrawButton("初始化", InitializeAsync); + DrawButton("重新初始化", ReinitializeAsync); GUILayout.EndHorizontal(); EndSection(); } private void DrawLoginSection() { - BeginSection("Login"); - LoginProvider = DrawEditableRow("Login Provider", LoginProvider); - LoginUserId = DrawEditableRow("Login User Id", LoginUserId); - LoginCode = DrawEditableRow("Login Code", LoginCode); - Nickname = DrawEditableRow("Nickname", Nickname); - AvatarUrl = DrawEditableRow("Avatar Url", AvatarUrl); + BeginSection("登录"); + LoginProvider = DrawEditableRow("登录提供方", LoginProvider); + LoginUserId = DrawEditableRow("登录用户 ID", LoginUserId); + LoginCode = DrawEditableRow("登录 Code", LoginCode); + Nickname = DrawEditableRow("昵称", Nickname); + AvatarUrl = DrawEditableRow("头像地址", AvatarUrl); GUILayout.BeginHorizontal(); - DrawButton("Login By UserId", LoginWithUserIdAsync, Brisk.IsInitialized); - DrawButton("Login By Code", LoginWithCodeAsync, Brisk.IsInitialized); - DrawButton("Logout", LogoutAsync, Brisk.IsInitialized); + DrawButton("按用户 ID 登录", LoginWithUserIdAsync, Brisk.IsInitialized); + DrawButton("按 Code 登录", LoginWithCodeAsync, Brisk.IsInitialized); + DrawButton("登出", LogoutAsync, Brisk.IsInitialized); GUILayout.EndHorizontal(); EndSection(); } private void DrawPlayerAndConfigSection() { - BeginSection("Player And Config"); + BeginSection("玩家与配置"); GUILayout.BeginHorizontal(); - DrawButton("Get Me", GetMeAsync, Brisk.IsLoggedIn); - DrawButton("Get Config Current", GetConfigAsync, Brisk.IsInitialized); - DrawButton("Apply Current Identity To Space", () => + DrawButton("获取当前玩家", GetMeAsync, Brisk.IsLoggedIn); + DrawButton("获取当前配置", GetConfigAsync, Brisk.IsInitialized); + DrawButton("同步当前身份到空间查询", () => { ApplyCurrentIdentityToSpace(); - SetResult("Space Lookup Identity", new Dictionary + SetResult("空间查询身份", new Dictionary { { "space_player_id", SpacePlayerId }, { "space_login_provider", SpaceLoginProvider }, @@ -213,103 +213,103 @@ public sealed class BriskQuickStartSample : MonoBehaviour private void DrawAnnouncementsSection() { - BeginSection("Announcements"); - AnnouncementId = DrawEditableRow("Announcement Id", AnnouncementId); + BeginSection("公告"); + AnnouncementId = DrawEditableRow("公告 ID", AnnouncementId); GUILayout.BeginHorizontal(); - DrawButton("Get Announcement List", GetAnnouncementsAsync, Brisk.IsLoggedIn); - DrawButton("Mark Read", MarkAnnouncementAsync, Brisk.IsLoggedIn); - DrawButton("Mark First Cached", MarkFirstCachedAnnouncementAsync, Brisk.IsLoggedIn && _announcementCache.Count > 0); + DrawButton("获取公告列表", GetAnnouncementsAsync, Brisk.IsLoggedIn); + DrawButton("标记已读", MarkAnnouncementAsync, Brisk.IsLoggedIn); + DrawButton("标记首条缓存公告已读", MarkFirstCachedAnnouncementAsync, Brisk.IsLoggedIn && _announcementCache.Count > 0); GUILayout.EndHorizontal(); EndSection(); } private void DrawLeaderboardSection() { - BeginSection("Leaderboard"); - RankKey = DrawEditableRow("Rank Key", RankKey); - SubmitScoreValue = DrawEditableRow("Submit Score", SubmitScoreValue); - LeaderboardLimit = DrawEditableRow("Top Limit", LeaderboardLimit); - AroundMeRange = DrawEditableRow("Around Range", AroundMeRange); - SeasonId = DrawEditableRow("Season Id", SeasonId); - SeasonHistoryLimit = DrawEditableRow("History Limit", SeasonHistoryLimit); + BeginSection("排行榜"); + RankKey = DrawEditableRow("排行榜 Key", RankKey); + SubmitScoreValue = DrawEditableRow("提交分数", SubmitScoreValue); + LeaderboardLimit = DrawEditableRow("Top 数量", LeaderboardLimit); + AroundMeRange = DrawEditableRow("附近范围", AroundMeRange); + SeasonId = DrawEditableRow("赛季 ID", SeasonId); + SeasonHistoryLimit = DrawEditableRow("历史条数", SeasonHistoryLimit); GUILayout.BeginHorizontal(); - DrawButton("Get Top", GetTopAsync, Brisk.IsLoggedIn); - DrawButton("Get My Rank", GetMyRankAsync, Brisk.IsLoggedIn); - DrawButton("Get Around Me", GetAroundMeAsync, Brisk.IsLoggedIn); + DrawButton("获取 Top", GetTopAsync, Brisk.IsLoggedIn); + DrawButton("获取我的排名", GetMyRankAsync, Brisk.IsLoggedIn); + DrawButton("获取我附近的排名", GetAroundMeAsync, Brisk.IsLoggedIn); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); - DrawButton("Submit Score", SubmitScoreAsync, Brisk.IsLoggedIn); - DrawButton("Get Current Season", GetCurrentSeasonAsync, Brisk.IsLoggedIn); - DrawButton("Get Season History", GetSeasonHistoryAsync, Brisk.IsLoggedIn); - DrawButton("Get Season Detail", GetSeasonDetailAsync, Brisk.IsLoggedIn); + DrawButton("提交分数", SubmitScoreAsync, Brisk.IsLoggedIn); + DrawButton("获取当前赛季", GetCurrentSeasonAsync, Brisk.IsLoggedIn); + DrawButton("获取赛季历史", GetSeasonHistoryAsync, Brisk.IsLoggedIn); + DrawButton("获取赛季详情", GetSeasonDetailAsync, Brisk.IsLoggedIn); GUILayout.EndHorizontal(); EndSection(); } private void DrawArchiveSection() { - BeginSection("Archive"); - ArchiveSlotNo = DrawEditableRow("Slot No", ArchiveSlotNo); - ArchiveBaseVersion = DrawEditableRow("Base Version", ArchiveBaseVersion); - ArchiveContent = DrawTextAreaRow("Archive Content", ArchiveContent, 90f); + BeginSection("云存档"); + ArchiveSlotNo = DrawEditableRow("槽位号", ArchiveSlotNo); + ArchiveBaseVersion = DrawEditableRow("基准版本", ArchiveBaseVersion); + ArchiveContent = DrawTextAreaRow("存档内容", ArchiveContent, 90f); GUILayout.BeginHorizontal(); - DrawButton("Get Slots", GetArchiveSlotsAsync, Brisk.IsLoggedIn); - DrawButton("Get Meta", GetArchiveMetaAsync, Brisk.IsLoggedIn); - DrawButton("Upload Text", UploadArchiveAsync, Brisk.IsLoggedIn); - DrawButton("Download", DownloadArchiveAsync, Brisk.IsLoggedIn); + DrawButton("获取槽位列表", GetArchiveSlotsAsync, Brisk.IsLoggedIn); + DrawButton("获取存档元信息", GetArchiveMetaAsync, Brisk.IsLoggedIn); + DrawButton("上传文本存档", UploadArchiveAsync, Brisk.IsLoggedIn); + DrawButton("下载存档", DownloadArchiveAsync, Brisk.IsLoggedIn); GUILayout.EndHorizontal(); EndSection(); } private void DrawSpaceSection() { - BeginSection("Space"); - SpacePlayerId = DrawEditableRow("Space Player Id", SpacePlayerId); - SpaceLoginProvider = DrawEditableRow("Space Login Provider", SpaceLoginProvider); - SpaceLoginUserId = DrawEditableRow("Space Login User Id", SpaceLoginUserId); - SpacePayloadText = DrawTextAreaRow("Space Payload Text", SpacePayloadText, 90f); + BeginSection("玩家空间"); + SpacePlayerId = DrawEditableRow("空间 PlayerId", SpacePlayerId); + SpaceLoginProvider = DrawEditableRow("空间登录提供方", SpaceLoginProvider); + SpaceLoginUserId = DrawEditableRow("空间登录用户 ID", SpaceLoginUserId); + SpacePayloadText = DrawTextAreaRow("空间 Payload 文本", SpacePayloadText, 90f); GUILayout.BeginHorizontal(); - DrawButton("Get By PlayerId", GetSpaceByPlayerIdAsync, Brisk.IsLoggedIn); - DrawButton("Get By Login", GetSpaceByLoginAsync, Brisk.IsLoggedIn); - DrawButton("Get Stats By PlayerId", GetSpaceStatsByPlayerIdAsync, Brisk.IsLoggedIn); - DrawButton("Get Stats By Login", GetSpaceStatsByLoginAsync, Brisk.IsLoggedIn); + DrawButton("按 PlayerId 获取空间", GetSpaceByPlayerIdAsync, Brisk.IsLoggedIn); + DrawButton("按登录身份获取空间", GetSpaceByLoginAsync, Brisk.IsLoggedIn); + DrawButton("按 PlayerId 获取统计", GetSpaceStatsByPlayerIdAsync, Brisk.IsLoggedIn); + DrawButton("按登录身份获取统计", GetSpaceStatsByLoginAsync, Brisk.IsLoggedIn); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); - DrawButton("Like PlayerId", LikeByPlayerIdAsync, Brisk.IsLoggedIn); - DrawButton("Unlike PlayerId", UnlikeByPlayerIdAsync, Brisk.IsLoggedIn); - DrawButton("Like Login", LikeByLoginAsync, Brisk.IsLoggedIn); - DrawButton("Unlike Login", UnlikeByLoginAsync, Brisk.IsLoggedIn); + DrawButton("按 PlayerId 点赞", LikeByPlayerIdAsync, Brisk.IsLoggedIn); + DrawButton("按 PlayerId 取消点赞", UnlikeByPlayerIdAsync, Brisk.IsLoggedIn); + DrawButton("按登录身份点赞", LikeByLoginAsync, Brisk.IsLoggedIn); + DrawButton("按登录身份取消点赞", UnlikeByLoginAsync, Brisk.IsLoggedIn); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); - DrawButton("Update My Space", UpdateMySpaceAsync, Brisk.IsLoggedIn); - DrawButton("Get My Visits", GetMyVisitsAsync, Brisk.IsLoggedIn); + DrawButton("更新我的空间", UpdateMySpaceAsync, Brisk.IsLoggedIn); + DrawButton("获取我的访客", GetMyVisitsAsync, Brisk.IsLoggedIn); GUILayout.EndHorizontal(); EndSection(); } private void DrawOutputSection() { - BeginSection("Output"); - GUILayout.Label("Latest Result", GUI.skin.label); + BeginSection("输出"); + GUILayout.Label("最近一次结果", GUI.skin.label); _resultScroll = GUILayout.BeginScrollView(_resultScroll, GUILayout.Height(240f)); GUILayout.TextArea(_resultText, GUILayout.ExpandHeight(true)); GUILayout.EndScrollView(); GUILayout.Space(8f); - GUILayout.Label("Latest Error", GUI.skin.label); - GUILayout.TextArea(string.IsNullOrWhiteSpace(_lastErrorText) ? "No error." : _lastErrorText, GUILayout.Height(90f)); + GUILayout.Label("最近一次错误", GUI.skin.label); + GUILayout.TextArea(string.IsNullOrWhiteSpace(_lastErrorText) ? "暂无错误。" : _lastErrorText, GUILayout.Height(90f)); GUILayout.Space(8f); - GUILayout.Label("Event Log", GUI.skin.label); + GUILayout.Label("事件日志", GUI.skin.label); _logScroll = GUILayout.BeginScrollView(_logScroll, GUILayout.Height(220f)); - GUILayout.TextArea(_eventLogs.Count == 0 ? "No events yet." : string.Join("\n", _eventLogs.ToArray()), GUILayout.ExpandHeight(true)); + GUILayout.TextArea(_eventLogs.Count == 0 ? "暂无事件。" : string.Join("\n", _eventLogs.ToArray()), GUILayout.ExpandHeight(true)); GUILayout.EndScrollView(); EndSection(); } @@ -326,7 +326,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour ExitHandler = HandleExitRequested }); - SetResult("Initialize Result", Brisk.Bootstrap); + SetResult("初始化结果", Brisk.Bootstrap); } private async Task ReinitializeAsync() @@ -334,7 +334,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour if (Brisk.IsInitialized) { Brisk.Shutdown(); - Log("SDK shutdown before reinitialize."); + Log("重新初始化前已先关闭 SDK。"); } await InitializeAsync(); @@ -344,20 +344,20 @@ public sealed class BriskQuickStartSample : MonoBehaviour { var result = await Brisk.Auth.LoginWithUserIdAsync(LoginProvider, LoginUserId, CreateProfile()); ApplyIdentity(result.PlayerId, result.LoginProvider, result.LoginUserId); - SetResult("Login By UserId Result", result); + SetResult("按用户 ID 登录结果", result); } private async Task LoginWithCodeAsync() { var result = await Brisk.Auth.LoginWithCodeAsync(LoginProvider, LoginCode, CreateProfile()); ApplyIdentity(result.PlayerId, result.LoginProvider, result.LoginUserId); - SetResult("Login By Code Result", result); + SetResult("按 Code 登录结果", result); } private async Task LogoutAsync() { await Brisk.Auth.LogoutAsync(); - SetResult("Logout Result", new Dictionary + SetResult("登出结果", new Dictionary { { "logged_in", Brisk.IsLoggedIn }, { "player_id", Brisk.PlayerId } @@ -368,13 +368,13 @@ public sealed class BriskQuickStartSample : MonoBehaviour { var me = await Brisk.Player.GetMeAsync(); ApplyIdentity(me.PlayerId, me.LoginProvider, me.LoginUserId); - SetResult("Player Me", me); + SetResult("当前玩家信息", me); } private async Task GetConfigAsync() { var config = await Brisk.Config.GetCurrentAsync(); - SetResult("Config Current", config); + SetResult("当前配置", config); } private async Task GetAnnouncementsAsync() @@ -385,52 +385,52 @@ public sealed class BriskQuickStartSample : MonoBehaviour AnnouncementId = _announcementCache[0].Id.ToString(); } - SetResult("Announcements", _announcementCache); + SetResult("公告列表", _announcementCache); } private async Task MarkAnnouncementAsync() { var id = ParseRequiredLong(AnnouncementId, nameof(AnnouncementId)); await Brisk.Announcements.MarkReadAsync(id); - SetResult("Announcement Marked Read", new Dictionary { { "announcement_id", id } }); + SetResult("公告已标记已读", new Dictionary { { "announcement_id", id } }); } private async Task MarkFirstCachedAnnouncementAsync() { if (_announcementCache.Count == 0) { - throw new InvalidOperationException("Announcement cache is empty. Run Get Announcement List first."); + throw new InvalidOperationException("公告缓存为空,请先执行“获取公告列表”。"); } var id = _announcementCache[0].Id; AnnouncementId = id.ToString(); await Brisk.Announcements.MarkReadAsync(id); - SetResult("First Cached Announcement Marked Read", _announcementCache[0]); + SetResult("首条缓存公告已标记已读", _announcementCache[0]); } private async Task GetTopAsync() { var result = await Brisk.Leaderboard.GetTopAsync(RankKey, ParseOptionalInt(LeaderboardLimit, 10)); - SetResult("Leaderboard Top", result); + SetResult("排行榜 Top", result); } private async Task GetMyRankAsync() { var result = await Brisk.Leaderboard.GetMeAsync(RankKey); - SetResult("Leaderboard My Rank", result); + SetResult("我的排行榜信息", result); } private async Task GetAroundMeAsync() { var result = await Brisk.Leaderboard.GetAroundMeAsync(RankKey, ParseOptionalInt(AroundMeRange, 5)); - SetResult("Leaderboard Around Me", result); + SetResult("我附近的排行榜", result); } private async Task SubmitScoreAsync() { var score = ParseRequiredLong(SubmitScoreValue, nameof(SubmitScoreValue)); await Brisk.Leaderboard.SubmitScoreAsync(RankKey, score); - SetResult("Score Submitted", new Dictionary + SetResult("分数提交结果", new Dictionary { { "rank_key", RankKey }, { "score", score } @@ -441,7 +441,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour { var result = await Brisk.Leaderboard.GetCurrentSeasonAsync(RankKey); SeasonId = result == null ? SeasonId : result.SeasonId; - SetResult("Current Season", result); + SetResult("当前赛季", result); } private async Task GetSeasonHistoryAsync() @@ -452,26 +452,26 @@ public sealed class BriskQuickStartSample : MonoBehaviour SeasonId = _seasonHistoryCache[0].SeasonId; } - SetResult("Season History", _seasonHistoryCache); + SetResult("赛季历史", _seasonHistoryCache); } private async Task GetSeasonDetailAsync() { var result = await Brisk.Leaderboard.GetSeasonHistoryDetailAsync(RankKey, SeasonId, ParseOptionalInt(SeasonHistoryLimit, 20)); - SetResult("Season Detail", result); + SetResult("赛季详情", result); } private async Task GetArchiveSlotsAsync() { var result = await Brisk.Archive.GetSlotsAsync(); - SetResult("Archive Slots", result); + SetResult("存档槽位列表", result); } private async Task GetArchiveMetaAsync() { var result = await Brisk.Archive.GetMetaAsync(ParseRequiredInt(ArchiveSlotNo, nameof(ArchiveSlotNo))); ArchiveBaseVersion = result == null ? ArchiveBaseVersion : result.Version.ToString(); - SetResult("Archive Meta", result); + SetResult("存档元信息", result); } private async Task UploadArchiveAsync() @@ -481,7 +481,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour var bytes = Encoding.UTF8.GetBytes(ArchiveContent ?? string.Empty); var result = await Brisk.Archive.UploadAsync(slotNo, bytes, baseVersion); ArchiveBaseVersion = result == null ? ArchiveBaseVersion : result.Version.ToString(); - SetResult("Archive Upload", result); + SetResult("存档上传结果", result); } private async Task DownloadArchiveAsync() @@ -497,49 +497,49 @@ public sealed class BriskQuickStartSample : MonoBehaviour { "text_preview", result.Bytes == null ? string.Empty : Encoding.UTF8.GetString(result.Bytes) } }; - SetResult("Archive Download", output); + SetResult("存档下载结果", output); } private async Task GetSpaceByPlayerIdAsync() { var result = await Brisk.Space.GetByPlayerIdAsync(SpacePlayerId); - SetResult("Space By PlayerId", result); + SetResult("按 PlayerId 获取空间", result); } private async Task GetSpaceByLoginAsync() { var result = await Brisk.Space.GetByLoginIdentityAsync(SpaceLoginProvider, SpaceLoginUserId); - SetResult("Space By Login", result); + SetResult("按登录身份获取空间", result); } private async Task GetSpaceStatsByPlayerIdAsync() { var result = await Brisk.Space.GetStatsByPlayerIdAsync(SpacePlayerId); - SetResult("Space Stats By PlayerId", result); + SetResult("按 PlayerId 获取空间统计", result); } private async Task GetSpaceStatsByLoginAsync() { var result = await Brisk.Space.GetStatsByLoginIdentityAsync(SpaceLoginProvider, SpaceLoginUserId); - SetResult("Space Stats By Login", result); + SetResult("按登录身份获取空间统计", result); } private async Task LikeByPlayerIdAsync() { await Brisk.Space.LikeByPlayerIdAsync(SpacePlayerId); - SetResult("Like By PlayerId", new Dictionary { { "player_id", SpacePlayerId } }); + SetResult("按 PlayerId 点赞结果", new Dictionary { { "player_id", SpacePlayerId } }); } private async Task UnlikeByPlayerIdAsync() { await Brisk.Space.UnlikeByPlayerIdAsync(SpacePlayerId); - SetResult("Unlike By PlayerId", new Dictionary { { "player_id", SpacePlayerId } }); + SetResult("按 PlayerId 取消点赞结果", new Dictionary { { "player_id", SpacePlayerId } }); } private async Task LikeByLoginAsync() { await Brisk.Space.LikeByLoginIdentityAsync(SpaceLoginProvider, SpaceLoginUserId); - SetResult("Like By Login", new Dictionary + SetResult("按登录身份点赞结果", new Dictionary { { "login_provider", SpaceLoginProvider }, { "login_user_id", SpaceLoginUserId } @@ -549,7 +549,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour private async Task UnlikeByLoginAsync() { await Brisk.Space.UnlikeByLoginIdentityAsync(SpaceLoginProvider, SpaceLoginUserId); - SetResult("Unlike By Login", new Dictionary + SetResult("按登录身份取消点赞结果", new Dictionary { { "login_provider", SpaceLoginProvider }, { "login_user_id", SpaceLoginUserId } @@ -567,13 +567,13 @@ public sealed class BriskQuickStartSample : MonoBehaviour }; await Brisk.Space.UpdateMyAsync(payload); - SetResult("Update My Space", payload); + SetResult("更新我的空间结果", payload); } private async Task GetMyVisitsAsync() { var result = await Brisk.Space.GetMyVisitsAsync(); - SetResult("My Space Visits", result); + SetResult("我的访客列表", result); } private async Task RunSmokeFlowAsync() @@ -619,21 +619,21 @@ public sealed class BriskQuickStartSample : MonoBehaviour { _isBusy = true; _busyAction = actionName; - _statusText = "Running: " + actionName; + _statusText = "执行中: " + actionName; _lastErrorText = string.Empty; - Log("Start: " + actionName); + Log("开始执行: " + actionName); try { await action(); - _statusText = "Success: " + actionName; - Log("Success: " + actionName); + _statusText = "执行成功: " + actionName; + Log("执行成功: " + actionName); } catch (Exception exception) { - _statusText = "Failed: " + actionName; + _statusText = "执行失败: " + actionName; _lastErrorText = FormatException(exception); - Log("Failed: " + actionName + " | " + exception.GetType().Name + " | " + exception.Message); + Log("执行失败: " + actionName + " | " + exception.GetType().Name + " | " + exception.Message); Debug.LogException(exception, this); } finally @@ -693,33 +693,33 @@ public sealed class BriskQuickStartSample : MonoBehaviour private void HandleInitialized() { - Log("Event: OnInitialized"); + Log("事件: 初始化完成"); } private void HandleLoggedIn() { - Log("Event: OnLoggedIn"); + Log("事件: 登录完成"); ApplyCurrentIdentityToSpace(); } private void HandleLoggedOut() { - Log("Event: OnLoggedOut"); + Log("事件: 登出完成"); } private void HandleAuthExpired(BriskAuthExpiredException exception) { - Log("Event: OnAuthExpired | " + exception.Message); + Log("事件: 登录态失效 | " + exception.Message); } private void HandleBlockingError(BriskBlockingException exception) { - Log("Event: OnBlockingError | " + exception.Message); + Log("事件: 严重阻断错误 | " + exception.Message); } private void HandleExitRequested() { - Log("Exit requested by Brisk blocking flow."); + Log("Brisk 阻断流程请求退出。"); } private void Log(string message) @@ -738,7 +738,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour { if (!int.TryParse(value, out var result)) { - throw new InvalidOperationException(fieldName + " must be a valid integer."); + throw new InvalidOperationException(fieldName + " 必须是合法整数。"); } return result; @@ -748,7 +748,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour { if (!long.TryParse(value, out var result)) { - throw new InvalidOperationException(fieldName + " must be a valid integer."); + throw new InvalidOperationException(fieldName + " 必须是合法整数。"); } return result; @@ -773,7 +773,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour { if (exception == null) { - return "Unknown error."; + return "未知错误。"; } var builder = new StringBuilder(); diff --git a/Assets/Scenes/BriskQuickStartScene.unity b/Assets/Scenes/BriskQuickStartScene.unity index 93e35f1..38bad70 100644 --- a/Assets/Scenes/BriskQuickStartScene.unity +++ b/Assets/Scenes/BriskQuickStartScene.unity @@ -257,7 +257,7 @@ MonoBehaviour: LoginProvider: tap LoginUserId: tap_user_10001 LoginCode: - Nickname: Unity Sample User + Nickname: Unity示例玩家 AvatarUrl: RankKey: season-score SubmitScoreValue: 128 @@ -267,10 +267,10 @@ MonoBehaviour: SeasonHistoryLimit: 20 ArchiveSlotNo: 1 ArchiveBaseVersion: - ArchiveContent: '{"save":1,"coins":128,"hero":"mage"}' + ArchiveContent: '{"save":1,"coins":128,"hero":"mage","title":"中文测试存档"}' AnnouncementId: SpacePlayerId: SpaceLoginProvider: tap SpaceLoginUserId: tap_user_10001 - SpacePayloadText: '{"mood":"ready","title":"hello brisk"}' + SpacePayloadText: '{"mood":"ready","title":"你好 Brisk","desc":"这是中文测试空间数据"}' AutoRunOnStart: 0 diff --git a/Brisk Package 发布流程.md b/Brisk Package 发布流程.md index 4d1a18f..a8e1e69 100644 --- a/Brisk Package 发布流程.md +++ b/Brisk Package 发布流程.md @@ -2,6 +2,10 @@ 本文档用于约定当前仓库的发布方式。 +仓库地址: + +- `http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git` + ## 开发态 当前仓库是 Unity 原始开发工程: @@ -41,6 +45,60 @@ 2. 从 `Assets/BriskSdk/Samples/QuickStart` 同步到 `PackageSource/com.foldcc.cc-framework.BriskGameServer/Samples~/QuickStart` 3. 把 `Assets/Scenes/BriskQuickStartScene.unity` 一并复制到 package sample 目录 +## 分支与 Tag 规范 + +建议采用以下命名: + +- 日常开发分支: + - `feature/...` + - `fix/...` +- 对外发包分支: + - `release/upm-vX.Y.Z` +- 对外发包 tag: + - `upm/vX.Y.Z` + +示例: + +- `release/upm-v0.1.0` +- `upm/v0.1.0` + +## 推荐发布动作 + +每次准备发版时,建议严格按以下顺序执行: + +1. 在开发分支完成 SDK 功能与测试 +2. 更新 `Assets` 下源码与示例场景 +3. 运行 `./Tools/Sync-BriskPackage.ps1` +4. 检查 `PackageSource/com.foldcc.cc-framework.BriskGameServer` 输出结果 +5. 更新 `package.json` 版本号 +6. 更新 `CHANGELOG.md` +7. 创建发布分支 `release/upm-vX.Y.Z` +8. 提交发布目录改动 +9. 打 tag `upm/vX.Y.Z` +10. 推送发布分支与 tag + +## 外部项目接入示例 + +外部项目通过 Git Package Manager 接入时,建议固定到 tag: + +```text +http://private.lightyears.ltd:18650/foldcc/CC-Framework.BriskGameServer.git?path=/PackageSource/com.foldcc.cc-framework.BriskGameServer#upm/v0.1.0 +``` + +这样做的好处: + +- 外部项目不会直接依赖整个 Unity 开发工程 +- 接入版本稳定,可回滚 +- package 内容和开发态源码解耦 + +## 当前注意事项 + +当前 `package.json` 中的包名仍然沿用既定命名: + +- `com.foldcc.cc-framework.BriskGameServer` + +这符合当前项目命名诉求,但从 UPM / npm 生态习惯看,正式大范围外发前,建议再确认一次是否需要改成全小写形式,以避免潜在兼容性问题。 + ## 建议发布流程 1. 在开发分支完成功能 diff --git a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Announcement/BriskAnnouncementsModule.cs b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Announcement/BriskAnnouncementsModule.cs index ea46be0..3e296f3 100644 --- a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Announcement/BriskAnnouncementsModule.cs +++ b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Announcement/BriskAnnouncementsModule.cs @@ -2,9 +2,15 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +/// +/// 公告模块。 +/// public sealed class BriskAnnouncementsModule : BriskModuleBase { + /// + /// 获取公告列表。 + /// public async Task> GetListAsync() { return await ExecuteAsync(async context => @@ -14,6 +20,9 @@ public sealed class BriskAnnouncementsModule }); } + /// + /// 标记指定公告为已读。 + /// public async Task MarkReadAsync(long id) { RequirePositive(id, nameof(id), "Announcement id must be greater than 0."); diff --git a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Archive/BriskArchiveModule.cs b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Archive/BriskArchiveModule.cs index 3e6d0cd..de9ed05 100644 --- a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Archive/BriskArchiveModule.cs +++ b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Archive/BriskArchiveModule.cs @@ -5,9 +5,15 @@ using System.Text; using System.Threading.Tasks; using UnityEngine.Networking; +/// +/// 云存档模块。 +/// public sealed class BriskArchiveModule : BriskModuleBase { + /// + /// 获取当前账号的存档槽位列表。 + /// public async Task> GetSlotsAsync() { return await ExecuteAsync(async context => @@ -17,6 +23,9 @@ public sealed class BriskArchiveModule }); } + /// + /// 获取指定槽位的元信息。 + /// public async Task GetMetaAsync(int slotNo) { ValidateSlotNo(slotNo); @@ -28,6 +37,9 @@ public sealed class BriskArchiveModule }); } + /// + /// 上传指定槽位的二进制存档。 + /// public async Task UploadAsync(int slotNo, byte[] bytes, int? baseVersion = null, string checksum = null) { ValidateSlotNo(slotNo); @@ -51,6 +63,9 @@ public sealed class BriskArchiveModule }); } + /// + /// 下载指定槽位的二进制存档。 + /// public async Task DownloadAsync(int slotNo) { ValidateSlotNo(slotNo); diff --git a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Auth/BriskAuthModule.cs b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Auth/BriskAuthModule.cs index 275d4ba..6219f6a 100644 --- a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Auth/BriskAuthModule.cs +++ b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Auth/BriskAuthModule.cs @@ -2,9 +2,15 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +/// +/// Brisk 认证模块。 +/// public sealed class BriskAuthModule : BriskModuleBase { + /// + /// 通过稳定的第三方用户 ID 换取 Brisk 登录态。 + /// public async Task LoginWithUserIdAsync(string loginProvider, string loginUserId, BriskProfile profile = null) { RequireNotEmpty(loginProvider, nameof(loginProvider)); @@ -13,6 +19,9 @@ public sealed class BriskAuthModule return await LoginInternalAsync(CreateLoginBody(loginProvider, profile, loginUserId, null), loginProvider, loginUserId); } + /// + /// 通过第三方返回的 code 换取 Brisk 登录态。 + /// public async Task LoginWithCodeAsync(string loginProvider, string code, BriskProfile profile = null) { RequireNotEmpty(loginProvider, nameof(loginProvider)); @@ -21,6 +30,9 @@ public sealed class BriskAuthModule return await LoginInternalAsync(CreateLoginBody(loginProvider, profile, null, code), loginProvider, null); } + /// + /// 登出当前账号并清理本地会话。 + /// public async Task LogoutAsync() { var context = GetContext(); diff --git a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Config/BriskConfigModule.cs b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Config/BriskConfigModule.cs index 75e71a8..b9f999b 100644 --- a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Config/BriskConfigModule.cs +++ b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Config/BriskConfigModule.cs @@ -2,9 +2,15 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +/// +/// 动态配置模块。 +/// public sealed class BriskConfigModule : BriskModuleBase { + /// + /// 获取当前客户端命中的动态配置。 + /// public async Task GetCurrentAsync() { return await ExecutePublicAsync(async context => @@ -14,6 +20,9 @@ public sealed class BriskConfigModule }); } + /// + /// 刷新并重新获取动态配置。 + /// public Task RefreshAsync() { return GetCurrentAsync(); diff --git a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Core/Brisk.cs b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Core/Brisk.cs index 4dd02f5..ff77830 100644 --- a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Core/Brisk.cs +++ b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Core/Brisk.cs @@ -2,6 +2,10 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +/// +/// Brisk SDK 的静态总入口。 +/// 初始化完成后,开发者可以通过 Brisk.AuthBrisk.Leaderboard 等模块直接访问能力。 +/// public static class Brisk { private static BriskContext s_context; @@ -17,40 +21,101 @@ public static class Brisk Space = new BriskSpaceModule(); } + /// + /// SDK 初始化完成后触发。 + /// public static event Action OnInitialized; + /// + /// 登录成功并保存会话后触发。 + /// public static event Action OnLoggedIn; + /// + /// 主动登出并清理本地会话后触发。 + /// public static event Action OnLoggedOut; + /// + /// 发生维护、封禁、强更等严重阻断错误时触发。 + /// public static event Action OnBlockingError; + /// + /// 登录态失效并清空本地会话时触发。 + /// public static event Action OnAuthExpired; + /// + /// 认证模块入口。 + /// public static BriskAuthModule Auth { get; } + /// + /// 玩家模块入口。 + /// public static BriskPlayerModule Player { get; } + /// + /// 动态配置模块入口。 + /// public static BriskConfigModule Config { get; } + /// + /// 公告模块入口。 + /// public static BriskAnnouncementsModule Announcements { get; } + /// + /// 排行榜模块入口。 + /// public static BriskLeaderboardModule Leaderboard { get; } + /// + /// 云存档模块入口。 + /// public static BriskArchiveModule Archive { get; } + /// + /// 玩家空间模块入口。 + /// public static BriskSpaceModule Space { get; } + /// + /// 当前 SDK 是否已完成初始化。 + /// public static bool IsInitialized => s_context != null; + /// + /// 当前是否存在可用登录态。 + /// public static bool IsLoggedIn => s_context != null && s_context.Session.HasAccessToken; + /// + /// 当前访问令牌。 + /// public static string AccessToken => s_context != null ? s_context.Session.AccessToken : null; + /// + /// 当前玩家 ID。 + /// public static string PlayerId => s_context != null ? s_context.Session.PlayerId : null; + /// + /// 当前登录身份摘要。 + /// public static BriskIdentity Identity => s_context != null ? s_context.Session.Identity : null; + /// + /// 当前初始化选项。 + /// public static BriskOptions Options => s_context != null ? s_context.Options : null; + /// + /// 初始化阶段获取到的 bootstrap 结果。 + /// public static BriskBootstrapResult Bootstrap => s_context != null ? s_context.Bootstrap : null; + /// + /// 初始化 SDK,并执行 bootstrap 与本地会话恢复。 + /// + /// 初始化选项。 public static async Task InitializeAsync(BriskOptions options) { if (options == null) @@ -79,16 +144,27 @@ public static class Brisk } } + /// + /// 关闭 SDK 并清空当前上下文。 + /// public static void Shutdown() { s_context = null; } + /// + /// 设置严重错误的展示器。 + /// + /// 自定义错误展示器;传入 null 时恢复默认展示器。 public static void SetErrorPresenter(IBriskErrorPresenter presenter) { GetRequiredContext().ErrorPresenter = presenter ?? BriskDefaultErrorPresenter.Instance; } + /// + /// 设置阻断错误确认后的退出回调。 + /// + /// 项目方自定义退出逻辑。 public static void SetExitHandler(Action exitHandler) { GetRequiredContext().ExitHandler = exitHandler; diff --git a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Core/BriskOptions.cs b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Core/BriskOptions.cs index a54deae..6bc6211 100644 --- a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Core/BriskOptions.cs +++ b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Core/BriskOptions.cs @@ -1,17 +1,50 @@ using System; +/// +/// Brisk SDK 初始化参数。 +/// public sealed class BriskOptions { + /// + /// 服务端基础地址。可以传主机地址,SDK 会自动补上 /api。 + /// public string BaseUrl; + /// + /// 项目标识。 + /// public string GameKey; + /// + /// 客户端版本号。 + /// public string ClientVersion; + /// + /// 设备标识。 + /// public string DeviceId; + /// + /// 是否启用调试日志。 + /// public bool EnableLog; + /// + /// 初始化时是否主动校验本地会话有效性。 + /// public bool ValidateSessionOnInitialize = true; + /// + /// 自定义登录态持久化实现。 + /// public IBriskTokenStore TokenStore; + /// + /// 自定义严重错误展示器。 + /// public IBriskErrorPresenter ErrorPresenter; + /// + /// 阻断错误确认后的退出处理逻辑。 + /// public Action ExitHandler; + /// + /// 校验并规范化初始化参数。 + /// public void Validate() { if (string.IsNullOrWhiteSpace(BaseUrl)) diff --git a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Core/IBriskErrorPresenter.cs b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Core/IBriskErrorPresenter.cs index 8dddfe3..4f85ea1 100644 --- a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Core/IBriskErrorPresenter.cs +++ b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Core/IBriskErrorPresenter.cs @@ -1,6 +1,15 @@ +/// +/// 自定义严重错误展示接口。 +/// public interface IBriskErrorPresenter { + /// + /// 展示维护、封禁、强更等阻断错误。 + /// void ShowBlockingError(BriskBlockingException exception); + /// + /// 展示登录态失效提示。 + /// void ShowAuthExpired(BriskAuthExpiredException exception); } diff --git a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Core/IBriskTokenStore.cs b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Core/IBriskTokenStore.cs index 9b452ff..d6127f6 100644 --- a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Core/IBriskTokenStore.cs +++ b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Core/IBriskTokenStore.cs @@ -1,10 +1,22 @@ using System.Threading.Tasks; +/// +/// 自定义登录态持久化接口。 +/// public interface IBriskTokenStore { + /// + /// 保存当前登录会话。 + /// Task SaveAsync(BriskStoredSession session); + /// + /// 读取本地保存的登录会话。 + /// Task LoadAsync(); + /// + /// 清空本地保存的登录会话。 + /// Task ClearAsync(); } diff --git a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Leaderboard/BriskLeaderboardModule.cs b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Leaderboard/BriskLeaderboardModule.cs index 6f8d171..7112196 100644 --- a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Leaderboard/BriskLeaderboardModule.cs +++ b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Leaderboard/BriskLeaderboardModule.cs @@ -2,9 +2,15 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +/// +/// 排行榜模块。 +/// public sealed class BriskLeaderboardModule : BriskModuleBase { + /// + /// 获取排行榜 Top 列表。 + /// public async Task> GetTopAsync(string rankKey, int limit = 20) { ValidateRankKey(rankKey); @@ -19,6 +25,9 @@ public sealed class BriskLeaderboardModule }); } + /// + /// 获取当前玩家在排行榜中的信息。 + /// public async Task GetMeAsync(string rankKey) { ValidateRankKey(rankKey); @@ -30,6 +39,9 @@ public sealed class BriskLeaderboardModule }); } + /// + /// 获取当前玩家附近的排名区间。 + /// public async Task> GetAroundMeAsync(string rankKey, int range = 10) { ValidateRankKey(rankKey); @@ -44,6 +56,9 @@ public sealed class BriskLeaderboardModule }); } + /// + /// 提交当前玩家分数。 + /// public async Task SubmitScoreAsync(string rankKey, long score) { ValidateRankKey(rankKey); @@ -57,6 +72,9 @@ public sealed class BriskLeaderboardModule }); } + /// + /// 获取当前赛季信息。 + /// public async Task GetCurrentSeasonAsync(string rankKey) { ValidateRankKey(rankKey); @@ -68,6 +86,9 @@ public sealed class BriskLeaderboardModule }); } + /// + /// 获取赛季历史列表。 + /// public async Task> GetSeasonHistoryAsync(string rankKey, int limit = 20) { ValidateRankKey(rankKey); @@ -82,6 +103,9 @@ public sealed class BriskLeaderboardModule }); } + /// + /// 获取指定历史赛季的排行榜详情。 + /// public async Task> GetSeasonHistoryDetailAsync(string rankKey, string seasonId, int limit = 20) { ValidateRankKey(rankKey); diff --git a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskConfigCurrent.cs b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskConfigCurrent.cs index 9f5e264..221c5f5 100644 --- a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskConfigCurrent.cs +++ b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskConfigCurrent.cs @@ -1,7 +1,16 @@ using System.Collections.Generic; +/// +/// 当前客户端命中的动态配置结果。 +/// public sealed class BriskConfigCurrent { + /// + /// 功能开关集合。 + /// public Dictionary FeatureFlags; + /// + /// 动态配置集合。 + /// public Dictionary DynamicConfig; } diff --git a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskIdentity.cs b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskIdentity.cs index fc2525a..bd9be7a 100644 --- a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskIdentity.cs +++ b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskIdentity.cs @@ -1,7 +1,22 @@ +/// +/// 当前登录身份摘要。 +/// public sealed class BriskIdentity { + /// + /// 登录提供方。 + /// public string LoginProvider; + /// + /// 登录用户 ID。 + /// public string LoginUserId; + /// + /// 玩家 ID。 + /// public string PlayerId; + /// + /// 项目账号 ID。 + /// public string ProjectAccountId; } diff --git a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskLoginResult.cs b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskLoginResult.cs index 536112c..950c40c 100644 --- a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskLoginResult.cs +++ b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskLoginResult.cs @@ -1,11 +1,38 @@ +/// +/// 登录成功后的返回结果。 +/// public sealed class BriskLoginResult { + /// + /// Brisk 访问令牌。 + /// public string AccessToken; + /// + /// 令牌有效时长,单位秒。 + /// public int ExpiresIn; + /// + /// 玩家 ID。 + /// public string PlayerId; + /// + /// 项目账号 ID。 + /// public string ProjectAccountId; + /// + /// 登录提供方。 + /// public string LoginProvider; + /// + /// 登录用户 ID。 + /// public string LoginUserId; + /// + /// 是否为新玩家。 + /// public bool IsNewPlayer; + /// + /// 玩家资料。 + /// public BriskProfile Profile; } diff --git a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskPlayerMe.cs b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskPlayerMe.cs index 5c929c2..5bc0580 100644 --- a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskPlayerMe.cs +++ b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskPlayerMe.cs @@ -1,10 +1,34 @@ +/// +/// 当前玩家资料。 +/// public sealed class BriskPlayerMe { + /// + /// 玩家 ID。 + /// public string PlayerId; + /// + /// 项目账号 ID。 + /// public string ProjectAccountId; + /// + /// 登录提供方。 + /// public string LoginProvider; + /// + /// 登录用户 ID。 + /// public string LoginUserId; + /// + /// 昵称。 + /// public string Nickname; + /// + /// 头像地址。 + /// public string AvatarUrl; + /// + /// 扩展资料。 + /// public object ProfileJson; } diff --git a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskProfile.cs b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskProfile.cs index 7acce66..98fc821 100644 --- a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskProfile.cs +++ b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Models/BriskProfile.cs @@ -1,6 +1,18 @@ +/// +/// 登录时可选上传的玩家资料。 +/// public sealed class BriskProfile { + /// + /// 玩家昵称。 + /// public string Nickname; + /// + /// 玩家头像地址。 + /// public string AvatarUrl; + /// + /// 额外扩展资料。 + /// public object ProfileJson; } diff --git a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Player/BriskPlayerModule.cs b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Player/BriskPlayerModule.cs index 6fdde7a..9c39493 100644 --- a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Player/BriskPlayerModule.cs +++ b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Player/BriskPlayerModule.cs @@ -1,9 +1,15 @@ using System; using System.Threading.Tasks; +/// +/// 玩家模块。 +/// public sealed class BriskPlayerModule : BriskModuleBase { + /// + /// 获取当前登录玩家信息。 + /// public async Task GetMeAsync() { return await ExecuteAsync(async context => diff --git a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Space/BriskSpaceModule.cs b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Space/BriskSpaceModule.cs index 18f4266..ebd61a8 100644 --- a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Space/BriskSpaceModule.cs +++ b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Runtime/Space/BriskSpaceModule.cs @@ -2,9 +2,15 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +/// +/// 玩家空间模块。 +/// public sealed class BriskSpaceModule : BriskModuleBase { + /// + /// 按玩家 ID 获取空间数据。 + /// public async Task GetByPlayerIdAsync(string playerId) { ValidatePlayerId(playerId); @@ -16,6 +22,9 @@ public sealed class BriskSpaceModule }); } + /// + /// 按登录身份获取空间数据。 + /// public async Task GetByLoginIdentityAsync(string loginProvider, string loginUserId) { ValidateLoginIdentity(loginProvider, loginUserId); @@ -27,6 +36,9 @@ public sealed class BriskSpaceModule }); } + /// + /// 按玩家 ID 获取空间统计。 + /// public async Task GetStatsByPlayerIdAsync(string playerId) { ValidatePlayerId(playerId); @@ -38,6 +50,9 @@ public sealed class BriskSpaceModule }); } + /// + /// 按登录身份获取空间统计。 + /// public async Task GetStatsByLoginIdentityAsync(string loginProvider, string loginUserId) { ValidateLoginIdentity(loginProvider, loginUserId); @@ -49,6 +64,9 @@ public sealed class BriskSpaceModule }); } + /// + /// 按玩家 ID 点赞空间。 + /// public async Task LikeByPlayerIdAsync(string playerId) { ValidatePlayerId(playerId); @@ -58,6 +76,9 @@ public sealed class BriskSpaceModule }); } + /// + /// 按玩家 ID 取消点赞空间。 + /// public async Task UnlikeByPlayerIdAsync(string playerId) { ValidatePlayerId(playerId); @@ -67,6 +88,9 @@ public sealed class BriskSpaceModule }); } + /// + /// 按登录身份点赞空间。 + /// public async Task LikeByLoginIdentityAsync(string loginProvider, string loginUserId) { ValidateLoginIdentity(loginProvider, loginUserId); @@ -76,6 +100,9 @@ public sealed class BriskSpaceModule }); } + /// + /// 按登录身份取消点赞空间。 + /// public async Task UnlikeByLoginIdentityAsync(string loginProvider, string loginUserId) { ValidateLoginIdentity(loginProvider, loginUserId); @@ -85,6 +112,9 @@ public sealed class BriskSpaceModule }); } + /// + /// 更新当前玩家自己的空间内容。 + /// public async Task UpdateMyAsync(object payload) { RequireNotNull(payload, nameof(payload)); @@ -98,6 +128,9 @@ public sealed class BriskSpaceModule }); } + /// + /// 获取我的访客列表。 + /// public async Task> GetMyVisitsAsync() { return await ExecuteAsync(async context => diff --git a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Samples~/QuickStart/BriskQuickStartSample.cs b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Samples~/QuickStart/BriskQuickStartSample.cs index 76f731d..b67477c 100644 --- a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Samples~/QuickStart/BriskQuickStartSample.cs +++ b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Samples~/QuickStart/BriskQuickStartSample.cs @@ -8,21 +8,21 @@ using UnityEngine; public sealed class BriskQuickStartSample : MonoBehaviour { - [Header("Init")] + [Header("初始化")] public string BaseUrl = "https://brisk.lightyears.ltd"; public string GameKey = "demo-game"; public string ClientVersion = "1.0.0"; public string DeviceId = "editor-device"; public bool ValidateSessionOnInitialize = true; - [Header("Login")] + [Header("登录")] public string LoginProvider = "tap"; public string LoginUserId = "tap_user_10001"; public string LoginCode = string.Empty; - public string Nickname = "Unity Sample User"; + public string Nickname = "Unity示例玩家"; public string AvatarUrl = string.Empty; - [Header("Leaderboard")] + [Header("排行榜")] public string RankKey = "season-score"; public string SubmitScoreValue = "128"; public string LeaderboardLimit = "10"; @@ -30,23 +30,23 @@ public sealed class BriskQuickStartSample : MonoBehaviour public string SeasonId = string.Empty; public string SeasonHistoryLimit = "20"; - [Header("Archive")] + [Header("云存档")] public string ArchiveSlotNo = "1"; public string ArchiveBaseVersion = string.Empty; [TextArea(3, 6)] - public string ArchiveContent = "{\n \"save\": 1,\n \"coins\": 128,\n \"hero\": \"mage\"\n}"; + public string ArchiveContent = "{\n \"save\": 1,\n \"coins\": 128,\n \"hero\": \"mage\",\n \"title\": \"中文测试存档\"\n}"; - [Header("Announcements")] + [Header("公告")] public string AnnouncementId = string.Empty; - [Header("Space")] + [Header("玩家空间")] public string SpacePlayerId = string.Empty; public string SpaceLoginProvider = "tap"; public string SpaceLoginUserId = "tap_user_10001"; [TextArea(3, 6)] - public string SpacePayloadText = "{\n \"mood\": \"ready\",\n \"title\": \"hello brisk\"\n}"; + public string SpacePayloadText = "{\n \"mood\": \"ready\",\n \"title\": \"你好 Brisk\",\n \"desc\": \"这是中文测试空间数据\"\n}"; - [Header("Demo")] + [Header("演示")] public bool AutoRunOnStart; private readonly List _eventLogs = new List(); @@ -56,8 +56,8 @@ public sealed class BriskQuickStartSample : MonoBehaviour private Vector2 _logScroll; private bool _isBusy; private string _busyAction = string.Empty; - private string _statusText = "Ready."; - private string _resultText = "No request yet."; + private string _statusText = "就绪"; + private string _resultText = "尚未执行请求。"; private string _lastErrorText = string.Empty; private IReadOnlyList _announcementCache = Array.Empty(); private IReadOnlyList _seasonHistoryCache = Array.Empty(); @@ -84,14 +84,14 @@ public sealed class BriskQuickStartSample : MonoBehaviour { if (AutoRunOnStart) { - RunAction("Auto Smoke Run", RunSmokeFlowAsync); + RunAction("自动冒烟流程", RunSmokeFlowAsync); } } - [ContextMenu("Run Brisk Sample")] + [ContextMenu("运行 Brisk 示例")] public void RunFromContextMenu() { - RunAction("Context Smoke Run", RunSmokeFlowAsync); + RunAction("右键菜单冒烟流程", RunSmokeFlowAsync); } private void OnGUI() @@ -117,40 +117,40 @@ public sealed class BriskQuickStartSample : MonoBehaviour private void DrawHeader() { - GUILayout.Label("Brisk IMGUI Sample", GUI.skin.box); - GUILayout.Label("This sample is designed for full SDK flow testing inside a single scene.", GUI.skin.label); + GUILayout.Label("Brisk IMGUI 测试面板", GUI.skin.box); + GUILayout.Label("这个场景用于在一个页面内测试 SDK 的完整流程。", GUI.skin.label); } private void DrawStatusPanel() { - BeginSection("Runtime Status"); - DrawReadOnlyRow("Initialized", Brisk.IsInitialized ? "Yes" : "No"); - DrawReadOnlyRow("Logged In", Brisk.IsLoggedIn ? "Yes" : "No"); + BeginSection("运行状态"); + DrawReadOnlyRow("已初始化", Brisk.IsInitialized ? "是" : "否"); + DrawReadOnlyRow("已登录", Brisk.IsLoggedIn ? "是" : "否"); DrawReadOnlyRow("PlayerId", Brisk.PlayerId); - DrawReadOnlyRow("Identity", Brisk.Identity == null ? string.Empty : Brisk.Identity.LoginProvider + " / " + Brisk.Identity.LoginUserId); - DrawReadOnlyRow("Current Action", _isBusy ? _busyAction : "Idle"); - DrawReadOnlyRow("Status", _statusText); + DrawReadOnlyRow("当前身份", Brisk.Identity == null ? string.Empty : Brisk.Identity.LoginProvider + " / " + Brisk.Identity.LoginUserId); + DrawReadOnlyRow("当前动作", _isBusy ? _busyAction : "空闲"); + DrawReadOnlyRow("状态", _statusText); GUILayout.BeginHorizontal(); - DrawButton("Run Smoke Flow", RunSmokeFlowAsync); - DrawButton("Show Bootstrap Cache", () => + DrawButton("执行冒烟流程", RunSmokeFlowAsync); + DrawButton("查看 Bootstrap 缓存", () => { - SetResult("Bootstrap Cache", Brisk.Bootstrap); + SetResult("Bootstrap 缓存", Brisk.Bootstrap); return Task.CompletedTask; }, Brisk.IsInitialized); - DrawButton("Shutdown SDK", () => + DrawButton("关闭 SDK", () => { Brisk.Shutdown(); - Log("SDK shutdown."); - _statusText = "SDK shutdown."; + Log("SDK 已关闭。"); + _statusText = "SDK 已关闭"; return Task.CompletedTask; }); - DrawButton("Clear Output", () => + DrawButton("清空输出", () => { - _resultText = "Output cleared."; + _resultText = "输出已清空。"; _lastErrorText = string.Empty; _eventLogs.Clear(); - _statusText = "Output cleared."; + _statusText = "输出已清空"; return Task.CompletedTask; }); GUILayout.EndHorizontal(); @@ -159,47 +159,47 @@ public sealed class BriskQuickStartSample : MonoBehaviour private void DrawInitSection() { - BeginSection("Initialize"); - BaseUrl = DrawEditableRow("Base Url", BaseUrl); - GameKey = DrawEditableRow("Game Key", GameKey); - ClientVersion = DrawEditableRow("Client Version", ClientVersion); - DeviceId = DrawEditableRow("Device Id", DeviceId); - ValidateSessionOnInitialize = DrawToggleRow("Validate Session On Init", ValidateSessionOnInitialize); + BeginSection("初始化"); + BaseUrl = DrawEditableRow("服务地址", BaseUrl); + GameKey = DrawEditableRow("游戏 Key", GameKey); + ClientVersion = DrawEditableRow("客户端版本", ClientVersion); + DeviceId = DrawEditableRow("设备标识", DeviceId); + ValidateSessionOnInitialize = DrawToggleRow("初始化时校验旧会话", ValidateSessionOnInitialize); GUILayout.BeginHorizontal(); - DrawButton("Initialize", InitializeAsync); - DrawButton("Reinitialize", ReinitializeAsync); + DrawButton("初始化", InitializeAsync); + DrawButton("重新初始化", ReinitializeAsync); GUILayout.EndHorizontal(); EndSection(); } private void DrawLoginSection() { - BeginSection("Login"); - LoginProvider = DrawEditableRow("Login Provider", LoginProvider); - LoginUserId = DrawEditableRow("Login User Id", LoginUserId); - LoginCode = DrawEditableRow("Login Code", LoginCode); - Nickname = DrawEditableRow("Nickname", Nickname); - AvatarUrl = DrawEditableRow("Avatar Url", AvatarUrl); + BeginSection("登录"); + LoginProvider = DrawEditableRow("登录提供方", LoginProvider); + LoginUserId = DrawEditableRow("登录用户 ID", LoginUserId); + LoginCode = DrawEditableRow("登录 Code", LoginCode); + Nickname = DrawEditableRow("昵称", Nickname); + AvatarUrl = DrawEditableRow("头像地址", AvatarUrl); GUILayout.BeginHorizontal(); - DrawButton("Login By UserId", LoginWithUserIdAsync, Brisk.IsInitialized); - DrawButton("Login By Code", LoginWithCodeAsync, Brisk.IsInitialized); - DrawButton("Logout", LogoutAsync, Brisk.IsInitialized); + DrawButton("按用户 ID 登录", LoginWithUserIdAsync, Brisk.IsInitialized); + DrawButton("按 Code 登录", LoginWithCodeAsync, Brisk.IsInitialized); + DrawButton("登出", LogoutAsync, Brisk.IsInitialized); GUILayout.EndHorizontal(); EndSection(); } private void DrawPlayerAndConfigSection() { - BeginSection("Player And Config"); + BeginSection("玩家与配置"); GUILayout.BeginHorizontal(); - DrawButton("Get Me", GetMeAsync, Brisk.IsLoggedIn); - DrawButton("Get Config Current", GetConfigAsync, Brisk.IsInitialized); - DrawButton("Apply Current Identity To Space", () => + DrawButton("获取当前玩家", GetMeAsync, Brisk.IsLoggedIn); + DrawButton("获取当前配置", GetConfigAsync, Brisk.IsInitialized); + DrawButton("同步当前身份到空间查询", () => { ApplyCurrentIdentityToSpace(); - SetResult("Space Lookup Identity", new Dictionary + SetResult("空间查询身份", new Dictionary { { "space_player_id", SpacePlayerId }, { "space_login_provider", SpaceLoginProvider }, @@ -213,103 +213,103 @@ public sealed class BriskQuickStartSample : MonoBehaviour private void DrawAnnouncementsSection() { - BeginSection("Announcements"); - AnnouncementId = DrawEditableRow("Announcement Id", AnnouncementId); + BeginSection("公告"); + AnnouncementId = DrawEditableRow("公告 ID", AnnouncementId); GUILayout.BeginHorizontal(); - DrawButton("Get Announcement List", GetAnnouncementsAsync, Brisk.IsLoggedIn); - DrawButton("Mark Read", MarkAnnouncementAsync, Brisk.IsLoggedIn); - DrawButton("Mark First Cached", MarkFirstCachedAnnouncementAsync, Brisk.IsLoggedIn && _announcementCache.Count > 0); + DrawButton("获取公告列表", GetAnnouncementsAsync, Brisk.IsLoggedIn); + DrawButton("标记已读", MarkAnnouncementAsync, Brisk.IsLoggedIn); + DrawButton("标记首条缓存公告已读", MarkFirstCachedAnnouncementAsync, Brisk.IsLoggedIn && _announcementCache.Count > 0); GUILayout.EndHorizontal(); EndSection(); } private void DrawLeaderboardSection() { - BeginSection("Leaderboard"); - RankKey = DrawEditableRow("Rank Key", RankKey); - SubmitScoreValue = DrawEditableRow("Submit Score", SubmitScoreValue); - LeaderboardLimit = DrawEditableRow("Top Limit", LeaderboardLimit); - AroundMeRange = DrawEditableRow("Around Range", AroundMeRange); - SeasonId = DrawEditableRow("Season Id", SeasonId); - SeasonHistoryLimit = DrawEditableRow("History Limit", SeasonHistoryLimit); + BeginSection("排行榜"); + RankKey = DrawEditableRow("排行榜 Key", RankKey); + SubmitScoreValue = DrawEditableRow("提交分数", SubmitScoreValue); + LeaderboardLimit = DrawEditableRow("Top 数量", LeaderboardLimit); + AroundMeRange = DrawEditableRow("附近范围", AroundMeRange); + SeasonId = DrawEditableRow("赛季 ID", SeasonId); + SeasonHistoryLimit = DrawEditableRow("历史条数", SeasonHistoryLimit); GUILayout.BeginHorizontal(); - DrawButton("Get Top", GetTopAsync, Brisk.IsLoggedIn); - DrawButton("Get My Rank", GetMyRankAsync, Brisk.IsLoggedIn); - DrawButton("Get Around Me", GetAroundMeAsync, Brisk.IsLoggedIn); + DrawButton("获取 Top", GetTopAsync, Brisk.IsLoggedIn); + DrawButton("获取我的排名", GetMyRankAsync, Brisk.IsLoggedIn); + DrawButton("获取我附近的排名", GetAroundMeAsync, Brisk.IsLoggedIn); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); - DrawButton("Submit Score", SubmitScoreAsync, Brisk.IsLoggedIn); - DrawButton("Get Current Season", GetCurrentSeasonAsync, Brisk.IsLoggedIn); - DrawButton("Get Season History", GetSeasonHistoryAsync, Brisk.IsLoggedIn); - DrawButton("Get Season Detail", GetSeasonDetailAsync, Brisk.IsLoggedIn); + DrawButton("提交分数", SubmitScoreAsync, Brisk.IsLoggedIn); + DrawButton("获取当前赛季", GetCurrentSeasonAsync, Brisk.IsLoggedIn); + DrawButton("获取赛季历史", GetSeasonHistoryAsync, Brisk.IsLoggedIn); + DrawButton("获取赛季详情", GetSeasonDetailAsync, Brisk.IsLoggedIn); GUILayout.EndHorizontal(); EndSection(); } private void DrawArchiveSection() { - BeginSection("Archive"); - ArchiveSlotNo = DrawEditableRow("Slot No", ArchiveSlotNo); - ArchiveBaseVersion = DrawEditableRow("Base Version", ArchiveBaseVersion); - ArchiveContent = DrawTextAreaRow("Archive Content", ArchiveContent, 90f); + BeginSection("云存档"); + ArchiveSlotNo = DrawEditableRow("槽位号", ArchiveSlotNo); + ArchiveBaseVersion = DrawEditableRow("基准版本", ArchiveBaseVersion); + ArchiveContent = DrawTextAreaRow("存档内容", ArchiveContent, 90f); GUILayout.BeginHorizontal(); - DrawButton("Get Slots", GetArchiveSlotsAsync, Brisk.IsLoggedIn); - DrawButton("Get Meta", GetArchiveMetaAsync, Brisk.IsLoggedIn); - DrawButton("Upload Text", UploadArchiveAsync, Brisk.IsLoggedIn); - DrawButton("Download", DownloadArchiveAsync, Brisk.IsLoggedIn); + DrawButton("获取槽位列表", GetArchiveSlotsAsync, Brisk.IsLoggedIn); + DrawButton("获取存档元信息", GetArchiveMetaAsync, Brisk.IsLoggedIn); + DrawButton("上传文本存档", UploadArchiveAsync, Brisk.IsLoggedIn); + DrawButton("下载存档", DownloadArchiveAsync, Brisk.IsLoggedIn); GUILayout.EndHorizontal(); EndSection(); } private void DrawSpaceSection() { - BeginSection("Space"); - SpacePlayerId = DrawEditableRow("Space Player Id", SpacePlayerId); - SpaceLoginProvider = DrawEditableRow("Space Login Provider", SpaceLoginProvider); - SpaceLoginUserId = DrawEditableRow("Space Login User Id", SpaceLoginUserId); - SpacePayloadText = DrawTextAreaRow("Space Payload Text", SpacePayloadText, 90f); + BeginSection("玩家空间"); + SpacePlayerId = DrawEditableRow("空间 PlayerId", SpacePlayerId); + SpaceLoginProvider = DrawEditableRow("空间登录提供方", SpaceLoginProvider); + SpaceLoginUserId = DrawEditableRow("空间登录用户 ID", SpaceLoginUserId); + SpacePayloadText = DrawTextAreaRow("空间 Payload 文本", SpacePayloadText, 90f); GUILayout.BeginHorizontal(); - DrawButton("Get By PlayerId", GetSpaceByPlayerIdAsync, Brisk.IsLoggedIn); - DrawButton("Get By Login", GetSpaceByLoginAsync, Brisk.IsLoggedIn); - DrawButton("Get Stats By PlayerId", GetSpaceStatsByPlayerIdAsync, Brisk.IsLoggedIn); - DrawButton("Get Stats By Login", GetSpaceStatsByLoginAsync, Brisk.IsLoggedIn); + DrawButton("按 PlayerId 获取空间", GetSpaceByPlayerIdAsync, Brisk.IsLoggedIn); + DrawButton("按登录身份获取空间", GetSpaceByLoginAsync, Brisk.IsLoggedIn); + DrawButton("按 PlayerId 获取统计", GetSpaceStatsByPlayerIdAsync, Brisk.IsLoggedIn); + DrawButton("按登录身份获取统计", GetSpaceStatsByLoginAsync, Brisk.IsLoggedIn); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); - DrawButton("Like PlayerId", LikeByPlayerIdAsync, Brisk.IsLoggedIn); - DrawButton("Unlike PlayerId", UnlikeByPlayerIdAsync, Brisk.IsLoggedIn); - DrawButton("Like Login", LikeByLoginAsync, Brisk.IsLoggedIn); - DrawButton("Unlike Login", UnlikeByLoginAsync, Brisk.IsLoggedIn); + DrawButton("按 PlayerId 点赞", LikeByPlayerIdAsync, Brisk.IsLoggedIn); + DrawButton("按 PlayerId 取消点赞", UnlikeByPlayerIdAsync, Brisk.IsLoggedIn); + DrawButton("按登录身份点赞", LikeByLoginAsync, Brisk.IsLoggedIn); + DrawButton("按登录身份取消点赞", UnlikeByLoginAsync, Brisk.IsLoggedIn); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); - DrawButton("Update My Space", UpdateMySpaceAsync, Brisk.IsLoggedIn); - DrawButton("Get My Visits", GetMyVisitsAsync, Brisk.IsLoggedIn); + DrawButton("更新我的空间", UpdateMySpaceAsync, Brisk.IsLoggedIn); + DrawButton("获取我的访客", GetMyVisitsAsync, Brisk.IsLoggedIn); GUILayout.EndHorizontal(); EndSection(); } private void DrawOutputSection() { - BeginSection("Output"); - GUILayout.Label("Latest Result", GUI.skin.label); + BeginSection("输出"); + GUILayout.Label("最近一次结果", GUI.skin.label); _resultScroll = GUILayout.BeginScrollView(_resultScroll, GUILayout.Height(240f)); GUILayout.TextArea(_resultText, GUILayout.ExpandHeight(true)); GUILayout.EndScrollView(); GUILayout.Space(8f); - GUILayout.Label("Latest Error", GUI.skin.label); - GUILayout.TextArea(string.IsNullOrWhiteSpace(_lastErrorText) ? "No error." : _lastErrorText, GUILayout.Height(90f)); + GUILayout.Label("最近一次错误", GUI.skin.label); + GUILayout.TextArea(string.IsNullOrWhiteSpace(_lastErrorText) ? "暂无错误。" : _lastErrorText, GUILayout.Height(90f)); GUILayout.Space(8f); - GUILayout.Label("Event Log", GUI.skin.label); + GUILayout.Label("事件日志", GUI.skin.label); _logScroll = GUILayout.BeginScrollView(_logScroll, GUILayout.Height(220f)); - GUILayout.TextArea(_eventLogs.Count == 0 ? "No events yet." : string.Join("\n", _eventLogs.ToArray()), GUILayout.ExpandHeight(true)); + GUILayout.TextArea(_eventLogs.Count == 0 ? "暂无事件。" : string.Join("\n", _eventLogs.ToArray()), GUILayout.ExpandHeight(true)); GUILayout.EndScrollView(); EndSection(); } @@ -326,7 +326,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour ExitHandler = HandleExitRequested }); - SetResult("Initialize Result", Brisk.Bootstrap); + SetResult("初始化结果", Brisk.Bootstrap); } private async Task ReinitializeAsync() @@ -334,7 +334,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour if (Brisk.IsInitialized) { Brisk.Shutdown(); - Log("SDK shutdown before reinitialize."); + Log("重新初始化前已先关闭 SDK。"); } await InitializeAsync(); @@ -344,20 +344,20 @@ public sealed class BriskQuickStartSample : MonoBehaviour { var result = await Brisk.Auth.LoginWithUserIdAsync(LoginProvider, LoginUserId, CreateProfile()); ApplyIdentity(result.PlayerId, result.LoginProvider, result.LoginUserId); - SetResult("Login By UserId Result", result); + SetResult("按用户 ID 登录结果", result); } private async Task LoginWithCodeAsync() { var result = await Brisk.Auth.LoginWithCodeAsync(LoginProvider, LoginCode, CreateProfile()); ApplyIdentity(result.PlayerId, result.LoginProvider, result.LoginUserId); - SetResult("Login By Code Result", result); + SetResult("按 Code 登录结果", result); } private async Task LogoutAsync() { await Brisk.Auth.LogoutAsync(); - SetResult("Logout Result", new Dictionary + SetResult("登出结果", new Dictionary { { "logged_in", Brisk.IsLoggedIn }, { "player_id", Brisk.PlayerId } @@ -368,13 +368,13 @@ public sealed class BriskQuickStartSample : MonoBehaviour { var me = await Brisk.Player.GetMeAsync(); ApplyIdentity(me.PlayerId, me.LoginProvider, me.LoginUserId); - SetResult("Player Me", me); + SetResult("当前玩家信息", me); } private async Task GetConfigAsync() { var config = await Brisk.Config.GetCurrentAsync(); - SetResult("Config Current", config); + SetResult("当前配置", config); } private async Task GetAnnouncementsAsync() @@ -385,52 +385,52 @@ public sealed class BriskQuickStartSample : MonoBehaviour AnnouncementId = _announcementCache[0].Id.ToString(); } - SetResult("Announcements", _announcementCache); + SetResult("公告列表", _announcementCache); } private async Task MarkAnnouncementAsync() { var id = ParseRequiredLong(AnnouncementId, nameof(AnnouncementId)); await Brisk.Announcements.MarkReadAsync(id); - SetResult("Announcement Marked Read", new Dictionary { { "announcement_id", id } }); + SetResult("公告已标记已读", new Dictionary { { "announcement_id", id } }); } private async Task MarkFirstCachedAnnouncementAsync() { if (_announcementCache.Count == 0) { - throw new InvalidOperationException("Announcement cache is empty. Run Get Announcement List first."); + throw new InvalidOperationException("公告缓存为空,请先执行“获取公告列表”。"); } var id = _announcementCache[0].Id; AnnouncementId = id.ToString(); await Brisk.Announcements.MarkReadAsync(id); - SetResult("First Cached Announcement Marked Read", _announcementCache[0]); + SetResult("首条缓存公告已标记已读", _announcementCache[0]); } private async Task GetTopAsync() { var result = await Brisk.Leaderboard.GetTopAsync(RankKey, ParseOptionalInt(LeaderboardLimit, 10)); - SetResult("Leaderboard Top", result); + SetResult("排行榜 Top", result); } private async Task GetMyRankAsync() { var result = await Brisk.Leaderboard.GetMeAsync(RankKey); - SetResult("Leaderboard My Rank", result); + SetResult("我的排行榜信息", result); } private async Task GetAroundMeAsync() { var result = await Brisk.Leaderboard.GetAroundMeAsync(RankKey, ParseOptionalInt(AroundMeRange, 5)); - SetResult("Leaderboard Around Me", result); + SetResult("我附近的排行榜", result); } private async Task SubmitScoreAsync() { var score = ParseRequiredLong(SubmitScoreValue, nameof(SubmitScoreValue)); await Brisk.Leaderboard.SubmitScoreAsync(RankKey, score); - SetResult("Score Submitted", new Dictionary + SetResult("分数提交结果", new Dictionary { { "rank_key", RankKey }, { "score", score } @@ -441,7 +441,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour { var result = await Brisk.Leaderboard.GetCurrentSeasonAsync(RankKey); SeasonId = result == null ? SeasonId : result.SeasonId; - SetResult("Current Season", result); + SetResult("当前赛季", result); } private async Task GetSeasonHistoryAsync() @@ -452,26 +452,26 @@ public sealed class BriskQuickStartSample : MonoBehaviour SeasonId = _seasonHistoryCache[0].SeasonId; } - SetResult("Season History", _seasonHistoryCache); + SetResult("赛季历史", _seasonHistoryCache); } private async Task GetSeasonDetailAsync() { var result = await Brisk.Leaderboard.GetSeasonHistoryDetailAsync(RankKey, SeasonId, ParseOptionalInt(SeasonHistoryLimit, 20)); - SetResult("Season Detail", result); + SetResult("赛季详情", result); } private async Task GetArchiveSlotsAsync() { var result = await Brisk.Archive.GetSlotsAsync(); - SetResult("Archive Slots", result); + SetResult("存档槽位列表", result); } private async Task GetArchiveMetaAsync() { var result = await Brisk.Archive.GetMetaAsync(ParseRequiredInt(ArchiveSlotNo, nameof(ArchiveSlotNo))); ArchiveBaseVersion = result == null ? ArchiveBaseVersion : result.Version.ToString(); - SetResult("Archive Meta", result); + SetResult("存档元信息", result); } private async Task UploadArchiveAsync() @@ -481,7 +481,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour var bytes = Encoding.UTF8.GetBytes(ArchiveContent ?? string.Empty); var result = await Brisk.Archive.UploadAsync(slotNo, bytes, baseVersion); ArchiveBaseVersion = result == null ? ArchiveBaseVersion : result.Version.ToString(); - SetResult("Archive Upload", result); + SetResult("存档上传结果", result); } private async Task DownloadArchiveAsync() @@ -497,49 +497,49 @@ public sealed class BriskQuickStartSample : MonoBehaviour { "text_preview", result.Bytes == null ? string.Empty : Encoding.UTF8.GetString(result.Bytes) } }; - SetResult("Archive Download", output); + SetResult("存档下载结果", output); } private async Task GetSpaceByPlayerIdAsync() { var result = await Brisk.Space.GetByPlayerIdAsync(SpacePlayerId); - SetResult("Space By PlayerId", result); + SetResult("按 PlayerId 获取空间", result); } private async Task GetSpaceByLoginAsync() { var result = await Brisk.Space.GetByLoginIdentityAsync(SpaceLoginProvider, SpaceLoginUserId); - SetResult("Space By Login", result); + SetResult("按登录身份获取空间", result); } private async Task GetSpaceStatsByPlayerIdAsync() { var result = await Brisk.Space.GetStatsByPlayerIdAsync(SpacePlayerId); - SetResult("Space Stats By PlayerId", result); + SetResult("按 PlayerId 获取空间统计", result); } private async Task GetSpaceStatsByLoginAsync() { var result = await Brisk.Space.GetStatsByLoginIdentityAsync(SpaceLoginProvider, SpaceLoginUserId); - SetResult("Space Stats By Login", result); + SetResult("按登录身份获取空间统计", result); } private async Task LikeByPlayerIdAsync() { await Brisk.Space.LikeByPlayerIdAsync(SpacePlayerId); - SetResult("Like By PlayerId", new Dictionary { { "player_id", SpacePlayerId } }); + SetResult("按 PlayerId 点赞结果", new Dictionary { { "player_id", SpacePlayerId } }); } private async Task UnlikeByPlayerIdAsync() { await Brisk.Space.UnlikeByPlayerIdAsync(SpacePlayerId); - SetResult("Unlike By PlayerId", new Dictionary { { "player_id", SpacePlayerId } }); + SetResult("按 PlayerId 取消点赞结果", new Dictionary { { "player_id", SpacePlayerId } }); } private async Task LikeByLoginAsync() { await Brisk.Space.LikeByLoginIdentityAsync(SpaceLoginProvider, SpaceLoginUserId); - SetResult("Like By Login", new Dictionary + SetResult("按登录身份点赞结果", new Dictionary { { "login_provider", SpaceLoginProvider }, { "login_user_id", SpaceLoginUserId } @@ -549,7 +549,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour private async Task UnlikeByLoginAsync() { await Brisk.Space.UnlikeByLoginIdentityAsync(SpaceLoginProvider, SpaceLoginUserId); - SetResult("Unlike By Login", new Dictionary + SetResult("按登录身份取消点赞结果", new Dictionary { { "login_provider", SpaceLoginProvider }, { "login_user_id", SpaceLoginUserId } @@ -567,13 +567,13 @@ public sealed class BriskQuickStartSample : MonoBehaviour }; await Brisk.Space.UpdateMyAsync(payload); - SetResult("Update My Space", payload); + SetResult("更新我的空间结果", payload); } private async Task GetMyVisitsAsync() { var result = await Brisk.Space.GetMyVisitsAsync(); - SetResult("My Space Visits", result); + SetResult("我的访客列表", result); } private async Task RunSmokeFlowAsync() @@ -619,21 +619,21 @@ public sealed class BriskQuickStartSample : MonoBehaviour { _isBusy = true; _busyAction = actionName; - _statusText = "Running: " + actionName; + _statusText = "执行中: " + actionName; _lastErrorText = string.Empty; - Log("Start: " + actionName); + Log("开始执行: " + actionName); try { await action(); - _statusText = "Success: " + actionName; - Log("Success: " + actionName); + _statusText = "执行成功: " + actionName; + Log("执行成功: " + actionName); } catch (Exception exception) { - _statusText = "Failed: " + actionName; + _statusText = "执行失败: " + actionName; _lastErrorText = FormatException(exception); - Log("Failed: " + actionName + " | " + exception.GetType().Name + " | " + exception.Message); + Log("执行失败: " + actionName + " | " + exception.GetType().Name + " | " + exception.Message); Debug.LogException(exception, this); } finally @@ -693,33 +693,33 @@ public sealed class BriskQuickStartSample : MonoBehaviour private void HandleInitialized() { - Log("Event: OnInitialized"); + Log("事件: 初始化完成"); } private void HandleLoggedIn() { - Log("Event: OnLoggedIn"); + Log("事件: 登录完成"); ApplyCurrentIdentityToSpace(); } private void HandleLoggedOut() { - Log("Event: OnLoggedOut"); + Log("事件: 登出完成"); } private void HandleAuthExpired(BriskAuthExpiredException exception) { - Log("Event: OnAuthExpired | " + exception.Message); + Log("事件: 登录态失效 | " + exception.Message); } private void HandleBlockingError(BriskBlockingException exception) { - Log("Event: OnBlockingError | " + exception.Message); + Log("事件: 严重阻断错误 | " + exception.Message); } private void HandleExitRequested() { - Log("Exit requested by Brisk blocking flow."); + Log("Brisk 阻断流程请求退出。"); } private void Log(string message) @@ -738,7 +738,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour { if (!int.TryParse(value, out var result)) { - throw new InvalidOperationException(fieldName + " must be a valid integer."); + throw new InvalidOperationException(fieldName + " 必须是合法整数。"); } return result; @@ -748,7 +748,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour { if (!long.TryParse(value, out var result)) { - throw new InvalidOperationException(fieldName + " must be a valid integer."); + throw new InvalidOperationException(fieldName + " 必须是合法整数。"); } return result; @@ -773,7 +773,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour { if (exception == null) { - return "Unknown error."; + return "未知错误。"; } var builder = new StringBuilder(); diff --git a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Samples~/QuickStart/BriskQuickStartScene.unity b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Samples~/QuickStart/BriskQuickStartScene.unity index 93e35f1..38bad70 100644 --- a/PackageSource/com.foldcc.cc-framework.BriskGameServer/Samples~/QuickStart/BriskQuickStartScene.unity +++ b/PackageSource/com.foldcc.cc-framework.BriskGameServer/Samples~/QuickStart/BriskQuickStartScene.unity @@ -257,7 +257,7 @@ MonoBehaviour: LoginProvider: tap LoginUserId: tap_user_10001 LoginCode: - Nickname: Unity Sample User + Nickname: Unity示例玩家 AvatarUrl: RankKey: season-score SubmitScoreValue: 128 @@ -267,10 +267,10 @@ MonoBehaviour: SeasonHistoryLimit: 20 ArchiveSlotNo: 1 ArchiveBaseVersion: - ArchiveContent: '{"save":1,"coins":128,"hero":"mage"}' + ArchiveContent: '{"save":1,"coins":128,"hero":"mage","title":"中文测试存档"}' AnnouncementId: SpacePlayerId: SpaceLoginProvider: tap SpaceLoginUserId: tap_user_10001 - SpacePayloadText: '{"mood":"ready","title":"hello brisk"}' + SpacePayloadText: '{"mood":"ready","title":"你好 Brisk","desc":"这是中文测试空间数据"}' AutoRunOnStart: 0