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