You've already forked CC-Framework.BriskGameServer
Localize sample UI and document release conventions
This commit is contained in:
@@ -8,21 +8,21 @@ using UnityEngine;
|
||||
|
||||
public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
{
|
||||
[Header("Init")]
|
||||
[Header("初始化")]
|
||||
public string BaseUrl = "https://brisk.lightyears.ltd";
|
||||
public string GameKey = "demo-game";
|
||||
public string ClientVersion = "1.0.0";
|
||||
public string DeviceId = "editor-device";
|
||||
public bool ValidateSessionOnInitialize = true;
|
||||
|
||||
[Header("Login")]
|
||||
[Header("登录")]
|
||||
public string LoginProvider = "tap";
|
||||
public string LoginUserId = "tap_user_10001";
|
||||
public string LoginCode = string.Empty;
|
||||
public string Nickname = "Unity Sample User";
|
||||
public string Nickname = "Unity示例玩家";
|
||||
public string AvatarUrl = string.Empty;
|
||||
|
||||
[Header("Leaderboard")]
|
||||
[Header("排行榜")]
|
||||
public string RankKey = "season-score";
|
||||
public string SubmitScoreValue = "128";
|
||||
public string LeaderboardLimit = "10";
|
||||
@@ -30,23 +30,23 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
public string SeasonId = string.Empty;
|
||||
public string SeasonHistoryLimit = "20";
|
||||
|
||||
[Header("Archive")]
|
||||
[Header("云存档")]
|
||||
public string ArchiveSlotNo = "1";
|
||||
public string ArchiveBaseVersion = string.Empty;
|
||||
[TextArea(3, 6)]
|
||||
public string ArchiveContent = "{\n \"save\": 1,\n \"coins\": 128,\n \"hero\": \"mage\"\n}";
|
||||
public string ArchiveContent = "{\n \"save\": 1,\n \"coins\": 128,\n \"hero\": \"mage\",\n \"title\": \"中文测试存档\"\n}";
|
||||
|
||||
[Header("Announcements")]
|
||||
[Header("公告")]
|
||||
public string AnnouncementId = string.Empty;
|
||||
|
||||
[Header("Space")]
|
||||
[Header("玩家空间")]
|
||||
public string SpacePlayerId = string.Empty;
|
||||
public string SpaceLoginProvider = "tap";
|
||||
public string SpaceLoginUserId = "tap_user_10001";
|
||||
[TextArea(3, 6)]
|
||||
public string SpacePayloadText = "{\n \"mood\": \"ready\",\n \"title\": \"hello brisk\"\n}";
|
||||
public string SpacePayloadText = "{\n \"mood\": \"ready\",\n \"title\": \"你好 Brisk\",\n \"desc\": \"这是中文测试空间数据\"\n}";
|
||||
|
||||
[Header("Demo")]
|
||||
[Header("演示")]
|
||||
public bool AutoRunOnStart;
|
||||
|
||||
private readonly List<string> _eventLogs = new List<string>();
|
||||
@@ -56,8 +56,8 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
private Vector2 _logScroll;
|
||||
private bool _isBusy;
|
||||
private string _busyAction = string.Empty;
|
||||
private string _statusText = "Ready.";
|
||||
private string _resultText = "No request yet.";
|
||||
private string _statusText = "就绪";
|
||||
private string _resultText = "尚未执行请求。";
|
||||
private string _lastErrorText = string.Empty;
|
||||
private IReadOnlyList<BriskAnnouncementItem> _announcementCache = Array.Empty<BriskAnnouncementItem>();
|
||||
private IReadOnlyList<BriskRankSeasonInfo> _seasonHistoryCache = Array.Empty<BriskRankSeasonInfo>();
|
||||
@@ -84,14 +84,14 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
{
|
||||
if (AutoRunOnStart)
|
||||
{
|
||||
RunAction("Auto Smoke Run", RunSmokeFlowAsync);
|
||||
RunAction("自动冒烟流程", RunSmokeFlowAsync);
|
||||
}
|
||||
}
|
||||
|
||||
[ContextMenu("Run Brisk Sample")]
|
||||
[ContextMenu("运行 Brisk 示例")]
|
||||
public void RunFromContextMenu()
|
||||
{
|
||||
RunAction("Context Smoke Run", RunSmokeFlowAsync);
|
||||
RunAction("右键菜单冒烟流程", RunSmokeFlowAsync);
|
||||
}
|
||||
|
||||
private void OnGUI()
|
||||
@@ -117,40 +117,40 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
|
||||
private void DrawHeader()
|
||||
{
|
||||
GUILayout.Label("Brisk IMGUI Sample", GUI.skin.box);
|
||||
GUILayout.Label("This sample is designed for full SDK flow testing inside a single scene.", GUI.skin.label);
|
||||
GUILayout.Label("Brisk IMGUI 测试面板", GUI.skin.box);
|
||||
GUILayout.Label("这个场景用于在一个页面内测试 SDK 的完整流程。", GUI.skin.label);
|
||||
}
|
||||
|
||||
private void DrawStatusPanel()
|
||||
{
|
||||
BeginSection("Runtime Status");
|
||||
DrawReadOnlyRow("Initialized", Brisk.IsInitialized ? "Yes" : "No");
|
||||
DrawReadOnlyRow("Logged In", Brisk.IsLoggedIn ? "Yes" : "No");
|
||||
BeginSection("运行状态");
|
||||
DrawReadOnlyRow("已初始化", Brisk.IsInitialized ? "是" : "否");
|
||||
DrawReadOnlyRow("已登录", Brisk.IsLoggedIn ? "是" : "否");
|
||||
DrawReadOnlyRow("PlayerId", Brisk.PlayerId);
|
||||
DrawReadOnlyRow("Identity", Brisk.Identity == null ? string.Empty : Brisk.Identity.LoginProvider + " / " + Brisk.Identity.LoginUserId);
|
||||
DrawReadOnlyRow("Current Action", _isBusy ? _busyAction : "Idle");
|
||||
DrawReadOnlyRow("Status", _statusText);
|
||||
DrawReadOnlyRow("当前身份", Brisk.Identity == null ? string.Empty : Brisk.Identity.LoginProvider + " / " + Brisk.Identity.LoginUserId);
|
||||
DrawReadOnlyRow("当前动作", _isBusy ? _busyAction : "空闲");
|
||||
DrawReadOnlyRow("状态", _statusText);
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
DrawButton("Run Smoke Flow", RunSmokeFlowAsync);
|
||||
DrawButton("Show Bootstrap Cache", () =>
|
||||
DrawButton("执行冒烟流程", RunSmokeFlowAsync);
|
||||
DrawButton("查看 Bootstrap 缓存", () =>
|
||||
{
|
||||
SetResult("Bootstrap Cache", Brisk.Bootstrap);
|
||||
SetResult("Bootstrap 缓存", Brisk.Bootstrap);
|
||||
return Task.CompletedTask;
|
||||
}, Brisk.IsInitialized);
|
||||
DrawButton("Shutdown SDK", () =>
|
||||
DrawButton("关闭 SDK", () =>
|
||||
{
|
||||
Brisk.Shutdown();
|
||||
Log("SDK shutdown.");
|
||||
_statusText = "SDK shutdown.";
|
||||
Log("SDK 已关闭。");
|
||||
_statusText = "SDK 已关闭";
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
DrawButton("Clear Output", () =>
|
||||
DrawButton("清空输出", () =>
|
||||
{
|
||||
_resultText = "Output cleared.";
|
||||
_resultText = "输出已清空。";
|
||||
_lastErrorText = string.Empty;
|
||||
_eventLogs.Clear();
|
||||
_statusText = "Output cleared.";
|
||||
_statusText = "输出已清空";
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
GUILayout.EndHorizontal();
|
||||
@@ -159,47 +159,47 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
|
||||
private void DrawInitSection()
|
||||
{
|
||||
BeginSection("Initialize");
|
||||
BaseUrl = DrawEditableRow("Base Url", BaseUrl);
|
||||
GameKey = DrawEditableRow("Game Key", GameKey);
|
||||
ClientVersion = DrawEditableRow("Client Version", ClientVersion);
|
||||
DeviceId = DrawEditableRow("Device Id", DeviceId);
|
||||
ValidateSessionOnInitialize = DrawToggleRow("Validate Session On Init", ValidateSessionOnInitialize);
|
||||
BeginSection("初始化");
|
||||
BaseUrl = DrawEditableRow("服务地址", BaseUrl);
|
||||
GameKey = DrawEditableRow("游戏 Key", GameKey);
|
||||
ClientVersion = DrawEditableRow("客户端版本", ClientVersion);
|
||||
DeviceId = DrawEditableRow("设备标识", DeviceId);
|
||||
ValidateSessionOnInitialize = DrawToggleRow("初始化时校验旧会话", ValidateSessionOnInitialize);
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
DrawButton("Initialize", InitializeAsync);
|
||||
DrawButton("Reinitialize", ReinitializeAsync);
|
||||
DrawButton("初始化", InitializeAsync);
|
||||
DrawButton("重新初始化", ReinitializeAsync);
|
||||
GUILayout.EndHorizontal();
|
||||
EndSection();
|
||||
}
|
||||
|
||||
private void DrawLoginSection()
|
||||
{
|
||||
BeginSection("Login");
|
||||
LoginProvider = DrawEditableRow("Login Provider", LoginProvider);
|
||||
LoginUserId = DrawEditableRow("Login User Id", LoginUserId);
|
||||
LoginCode = DrawEditableRow("Login Code", LoginCode);
|
||||
Nickname = DrawEditableRow("Nickname", Nickname);
|
||||
AvatarUrl = DrawEditableRow("Avatar Url", AvatarUrl);
|
||||
BeginSection("登录");
|
||||
LoginProvider = DrawEditableRow("登录提供方", LoginProvider);
|
||||
LoginUserId = DrawEditableRow("登录用户 ID", LoginUserId);
|
||||
LoginCode = DrawEditableRow("登录 Code", LoginCode);
|
||||
Nickname = DrawEditableRow("昵称", Nickname);
|
||||
AvatarUrl = DrawEditableRow("头像地址", AvatarUrl);
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
DrawButton("Login By UserId", LoginWithUserIdAsync, Brisk.IsInitialized);
|
||||
DrawButton("Login By Code", LoginWithCodeAsync, Brisk.IsInitialized);
|
||||
DrawButton("Logout", LogoutAsync, Brisk.IsInitialized);
|
||||
DrawButton("按用户 ID 登录", LoginWithUserIdAsync, Brisk.IsInitialized);
|
||||
DrawButton("按 Code 登录", LoginWithCodeAsync, Brisk.IsInitialized);
|
||||
DrawButton("登出", LogoutAsync, Brisk.IsInitialized);
|
||||
GUILayout.EndHorizontal();
|
||||
EndSection();
|
||||
}
|
||||
|
||||
private void DrawPlayerAndConfigSection()
|
||||
{
|
||||
BeginSection("Player And Config");
|
||||
BeginSection("玩家与配置");
|
||||
GUILayout.BeginHorizontal();
|
||||
DrawButton("Get Me", GetMeAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("Get Config Current", GetConfigAsync, Brisk.IsInitialized);
|
||||
DrawButton("Apply Current Identity To Space", () =>
|
||||
DrawButton("获取当前玩家", GetMeAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("获取当前配置", GetConfigAsync, Brisk.IsInitialized);
|
||||
DrawButton("同步当前身份到空间查询", () =>
|
||||
{
|
||||
ApplyCurrentIdentityToSpace();
|
||||
SetResult("Space Lookup Identity", new Dictionary<string, object>
|
||||
SetResult("空间查询身份", new Dictionary<string, object>
|
||||
{
|
||||
{ "space_player_id", SpacePlayerId },
|
||||
{ "space_login_provider", SpaceLoginProvider },
|
||||
@@ -213,103 +213,103 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
|
||||
private void DrawAnnouncementsSection()
|
||||
{
|
||||
BeginSection("Announcements");
|
||||
AnnouncementId = DrawEditableRow("Announcement Id", AnnouncementId);
|
||||
BeginSection("公告");
|
||||
AnnouncementId = DrawEditableRow("公告 ID", AnnouncementId);
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
DrawButton("Get Announcement List", GetAnnouncementsAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("Mark Read", MarkAnnouncementAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("Mark First Cached", MarkFirstCachedAnnouncementAsync, Brisk.IsLoggedIn && _announcementCache.Count > 0);
|
||||
DrawButton("获取公告列表", GetAnnouncementsAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("标记已读", MarkAnnouncementAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("标记首条缓存公告已读", MarkFirstCachedAnnouncementAsync, Brisk.IsLoggedIn && _announcementCache.Count > 0);
|
||||
GUILayout.EndHorizontal();
|
||||
EndSection();
|
||||
}
|
||||
|
||||
private void DrawLeaderboardSection()
|
||||
{
|
||||
BeginSection("Leaderboard");
|
||||
RankKey = DrawEditableRow("Rank Key", RankKey);
|
||||
SubmitScoreValue = DrawEditableRow("Submit Score", SubmitScoreValue);
|
||||
LeaderboardLimit = DrawEditableRow("Top Limit", LeaderboardLimit);
|
||||
AroundMeRange = DrawEditableRow("Around Range", AroundMeRange);
|
||||
SeasonId = DrawEditableRow("Season Id", SeasonId);
|
||||
SeasonHistoryLimit = DrawEditableRow("History Limit", SeasonHistoryLimit);
|
||||
BeginSection("排行榜");
|
||||
RankKey = DrawEditableRow("排行榜 Key", RankKey);
|
||||
SubmitScoreValue = DrawEditableRow("提交分数", SubmitScoreValue);
|
||||
LeaderboardLimit = DrawEditableRow("Top 数量", LeaderboardLimit);
|
||||
AroundMeRange = DrawEditableRow("附近范围", AroundMeRange);
|
||||
SeasonId = DrawEditableRow("赛季 ID", SeasonId);
|
||||
SeasonHistoryLimit = DrawEditableRow("历史条数", SeasonHistoryLimit);
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
DrawButton("Get Top", GetTopAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("Get My Rank", GetMyRankAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("Get Around Me", GetAroundMeAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("获取 Top", GetTopAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("获取我的排名", GetMyRankAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("获取我附近的排名", GetAroundMeAsync, Brisk.IsLoggedIn);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
DrawButton("Submit Score", SubmitScoreAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("Get Current Season", GetCurrentSeasonAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("Get Season History", GetSeasonHistoryAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("Get Season Detail", GetSeasonDetailAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("提交分数", SubmitScoreAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("获取当前赛季", GetCurrentSeasonAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("获取赛季历史", GetSeasonHistoryAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("获取赛季详情", GetSeasonDetailAsync, Brisk.IsLoggedIn);
|
||||
GUILayout.EndHorizontal();
|
||||
EndSection();
|
||||
}
|
||||
|
||||
private void DrawArchiveSection()
|
||||
{
|
||||
BeginSection("Archive");
|
||||
ArchiveSlotNo = DrawEditableRow("Slot No", ArchiveSlotNo);
|
||||
ArchiveBaseVersion = DrawEditableRow("Base Version", ArchiveBaseVersion);
|
||||
ArchiveContent = DrawTextAreaRow("Archive Content", ArchiveContent, 90f);
|
||||
BeginSection("云存档");
|
||||
ArchiveSlotNo = DrawEditableRow("槽位号", ArchiveSlotNo);
|
||||
ArchiveBaseVersion = DrawEditableRow("基准版本", ArchiveBaseVersion);
|
||||
ArchiveContent = DrawTextAreaRow("存档内容", ArchiveContent, 90f);
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
DrawButton("Get Slots", GetArchiveSlotsAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("Get Meta", GetArchiveMetaAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("Upload Text", UploadArchiveAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("Download", DownloadArchiveAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("获取槽位列表", GetArchiveSlotsAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("获取存档元信息", GetArchiveMetaAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("上传文本存档", UploadArchiveAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("下载存档", DownloadArchiveAsync, Brisk.IsLoggedIn);
|
||||
GUILayout.EndHorizontal();
|
||||
EndSection();
|
||||
}
|
||||
|
||||
private void DrawSpaceSection()
|
||||
{
|
||||
BeginSection("Space");
|
||||
SpacePlayerId = DrawEditableRow("Space Player Id", SpacePlayerId);
|
||||
SpaceLoginProvider = DrawEditableRow("Space Login Provider", SpaceLoginProvider);
|
||||
SpaceLoginUserId = DrawEditableRow("Space Login User Id", SpaceLoginUserId);
|
||||
SpacePayloadText = DrawTextAreaRow("Space Payload Text", SpacePayloadText, 90f);
|
||||
BeginSection("玩家空间");
|
||||
SpacePlayerId = DrawEditableRow("空间 PlayerId", SpacePlayerId);
|
||||
SpaceLoginProvider = DrawEditableRow("空间登录提供方", SpaceLoginProvider);
|
||||
SpaceLoginUserId = DrawEditableRow("空间登录用户 ID", SpaceLoginUserId);
|
||||
SpacePayloadText = DrawTextAreaRow("空间 Payload 文本", SpacePayloadText, 90f);
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
DrawButton("Get By PlayerId", GetSpaceByPlayerIdAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("Get By Login", GetSpaceByLoginAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("Get Stats By PlayerId", GetSpaceStatsByPlayerIdAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("Get Stats By Login", GetSpaceStatsByLoginAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("按 PlayerId 获取空间", GetSpaceByPlayerIdAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("按登录身份获取空间", GetSpaceByLoginAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("按 PlayerId 获取统计", GetSpaceStatsByPlayerIdAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("按登录身份获取统计", GetSpaceStatsByLoginAsync, Brisk.IsLoggedIn);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
DrawButton("Like PlayerId", LikeByPlayerIdAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("Unlike PlayerId", UnlikeByPlayerIdAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("Like Login", LikeByLoginAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("Unlike Login", UnlikeByLoginAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("按 PlayerId 点赞", LikeByPlayerIdAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("按 PlayerId 取消点赞", UnlikeByPlayerIdAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("按登录身份点赞", LikeByLoginAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("按登录身份取消点赞", UnlikeByLoginAsync, Brisk.IsLoggedIn);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
DrawButton("Update My Space", UpdateMySpaceAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("Get My Visits", GetMyVisitsAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("更新我的空间", UpdateMySpaceAsync, Brisk.IsLoggedIn);
|
||||
DrawButton("获取我的访客", GetMyVisitsAsync, Brisk.IsLoggedIn);
|
||||
GUILayout.EndHorizontal();
|
||||
EndSection();
|
||||
}
|
||||
|
||||
private void DrawOutputSection()
|
||||
{
|
||||
BeginSection("Output");
|
||||
GUILayout.Label("Latest Result", GUI.skin.label);
|
||||
BeginSection("输出");
|
||||
GUILayout.Label("最近一次结果", GUI.skin.label);
|
||||
_resultScroll = GUILayout.BeginScrollView(_resultScroll, GUILayout.Height(240f));
|
||||
GUILayout.TextArea(_resultText, GUILayout.ExpandHeight(true));
|
||||
GUILayout.EndScrollView();
|
||||
|
||||
GUILayout.Space(8f);
|
||||
GUILayout.Label("Latest Error", GUI.skin.label);
|
||||
GUILayout.TextArea(string.IsNullOrWhiteSpace(_lastErrorText) ? "No error." : _lastErrorText, GUILayout.Height(90f));
|
||||
GUILayout.Label("最近一次错误", GUI.skin.label);
|
||||
GUILayout.TextArea(string.IsNullOrWhiteSpace(_lastErrorText) ? "暂无错误。" : _lastErrorText, GUILayout.Height(90f));
|
||||
|
||||
GUILayout.Space(8f);
|
||||
GUILayout.Label("Event Log", GUI.skin.label);
|
||||
GUILayout.Label("事件日志", GUI.skin.label);
|
||||
_logScroll = GUILayout.BeginScrollView(_logScroll, GUILayout.Height(220f));
|
||||
GUILayout.TextArea(_eventLogs.Count == 0 ? "No events yet." : string.Join("\n", _eventLogs.ToArray()), GUILayout.ExpandHeight(true));
|
||||
GUILayout.TextArea(_eventLogs.Count == 0 ? "暂无事件。" : string.Join("\n", _eventLogs.ToArray()), GUILayout.ExpandHeight(true));
|
||||
GUILayout.EndScrollView();
|
||||
EndSection();
|
||||
}
|
||||
@@ -326,7 +326,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
ExitHandler = HandleExitRequested
|
||||
});
|
||||
|
||||
SetResult("Initialize Result", Brisk.Bootstrap);
|
||||
SetResult("初始化结果", Brisk.Bootstrap);
|
||||
}
|
||||
|
||||
private async Task ReinitializeAsync()
|
||||
@@ -334,7 +334,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
if (Brisk.IsInitialized)
|
||||
{
|
||||
Brisk.Shutdown();
|
||||
Log("SDK shutdown before reinitialize.");
|
||||
Log("重新初始化前已先关闭 SDK。");
|
||||
}
|
||||
|
||||
await InitializeAsync();
|
||||
@@ -344,20 +344,20 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
{
|
||||
var result = await Brisk.Auth.LoginWithUserIdAsync(LoginProvider, LoginUserId, CreateProfile());
|
||||
ApplyIdentity(result.PlayerId, result.LoginProvider, result.LoginUserId);
|
||||
SetResult("Login By UserId Result", result);
|
||||
SetResult("按用户 ID 登录结果", result);
|
||||
}
|
||||
|
||||
private async Task LoginWithCodeAsync()
|
||||
{
|
||||
var result = await Brisk.Auth.LoginWithCodeAsync(LoginProvider, LoginCode, CreateProfile());
|
||||
ApplyIdentity(result.PlayerId, result.LoginProvider, result.LoginUserId);
|
||||
SetResult("Login By Code Result", result);
|
||||
SetResult("按 Code 登录结果", result);
|
||||
}
|
||||
|
||||
private async Task LogoutAsync()
|
||||
{
|
||||
await Brisk.Auth.LogoutAsync();
|
||||
SetResult("Logout Result", new Dictionary<string, object>
|
||||
SetResult("登出结果", new Dictionary<string, object>
|
||||
{
|
||||
{ "logged_in", Brisk.IsLoggedIn },
|
||||
{ "player_id", Brisk.PlayerId }
|
||||
@@ -368,13 +368,13 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
{
|
||||
var me = await Brisk.Player.GetMeAsync();
|
||||
ApplyIdentity(me.PlayerId, me.LoginProvider, me.LoginUserId);
|
||||
SetResult("Player Me", me);
|
||||
SetResult("当前玩家信息", me);
|
||||
}
|
||||
|
||||
private async Task GetConfigAsync()
|
||||
{
|
||||
var config = await Brisk.Config.GetCurrentAsync();
|
||||
SetResult("Config Current", config);
|
||||
SetResult("当前配置", config);
|
||||
}
|
||||
|
||||
private async Task GetAnnouncementsAsync()
|
||||
@@ -385,52 +385,52 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
AnnouncementId = _announcementCache[0].Id.ToString();
|
||||
}
|
||||
|
||||
SetResult("Announcements", _announcementCache);
|
||||
SetResult("公告列表", _announcementCache);
|
||||
}
|
||||
|
||||
private async Task MarkAnnouncementAsync()
|
||||
{
|
||||
var id = ParseRequiredLong(AnnouncementId, nameof(AnnouncementId));
|
||||
await Brisk.Announcements.MarkReadAsync(id);
|
||||
SetResult("Announcement Marked Read", new Dictionary<string, object> { { "announcement_id", id } });
|
||||
SetResult("公告已标记已读", new Dictionary<string, object> { { "announcement_id", id } });
|
||||
}
|
||||
|
||||
private async Task MarkFirstCachedAnnouncementAsync()
|
||||
{
|
||||
if (_announcementCache.Count == 0)
|
||||
{
|
||||
throw new InvalidOperationException("Announcement cache is empty. Run Get Announcement List first.");
|
||||
throw new InvalidOperationException("公告缓存为空,请先执行“获取公告列表”。");
|
||||
}
|
||||
|
||||
var id = _announcementCache[0].Id;
|
||||
AnnouncementId = id.ToString();
|
||||
await Brisk.Announcements.MarkReadAsync(id);
|
||||
SetResult("First Cached Announcement Marked Read", _announcementCache[0]);
|
||||
SetResult("首条缓存公告已标记已读", _announcementCache[0]);
|
||||
}
|
||||
|
||||
private async Task GetTopAsync()
|
||||
{
|
||||
var result = await Brisk.Leaderboard.GetTopAsync(RankKey, ParseOptionalInt(LeaderboardLimit, 10));
|
||||
SetResult("Leaderboard Top", result);
|
||||
SetResult("排行榜 Top", result);
|
||||
}
|
||||
|
||||
private async Task GetMyRankAsync()
|
||||
{
|
||||
var result = await Brisk.Leaderboard.GetMeAsync(RankKey);
|
||||
SetResult("Leaderboard My Rank", result);
|
||||
SetResult("我的排行榜信息", result);
|
||||
}
|
||||
|
||||
private async Task GetAroundMeAsync()
|
||||
{
|
||||
var result = await Brisk.Leaderboard.GetAroundMeAsync(RankKey, ParseOptionalInt(AroundMeRange, 5));
|
||||
SetResult("Leaderboard Around Me", result);
|
||||
SetResult("我附近的排行榜", result);
|
||||
}
|
||||
|
||||
private async Task SubmitScoreAsync()
|
||||
{
|
||||
var score = ParseRequiredLong(SubmitScoreValue, nameof(SubmitScoreValue));
|
||||
await Brisk.Leaderboard.SubmitScoreAsync(RankKey, score);
|
||||
SetResult("Score Submitted", new Dictionary<string, object>
|
||||
SetResult("分数提交结果", new Dictionary<string, object>
|
||||
{
|
||||
{ "rank_key", RankKey },
|
||||
{ "score", score }
|
||||
@@ -441,7 +441,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
{
|
||||
var result = await Brisk.Leaderboard.GetCurrentSeasonAsync(RankKey);
|
||||
SeasonId = result == null ? SeasonId : result.SeasonId;
|
||||
SetResult("Current Season", result);
|
||||
SetResult("当前赛季", result);
|
||||
}
|
||||
|
||||
private async Task GetSeasonHistoryAsync()
|
||||
@@ -452,26 +452,26 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
SeasonId = _seasonHistoryCache[0].SeasonId;
|
||||
}
|
||||
|
||||
SetResult("Season History", _seasonHistoryCache);
|
||||
SetResult("赛季历史", _seasonHistoryCache);
|
||||
}
|
||||
|
||||
private async Task GetSeasonDetailAsync()
|
||||
{
|
||||
var result = await Brisk.Leaderboard.GetSeasonHistoryDetailAsync(RankKey, SeasonId, ParseOptionalInt(SeasonHistoryLimit, 20));
|
||||
SetResult("Season Detail", result);
|
||||
SetResult("赛季详情", result);
|
||||
}
|
||||
|
||||
private async Task GetArchiveSlotsAsync()
|
||||
{
|
||||
var result = await Brisk.Archive.GetSlotsAsync();
|
||||
SetResult("Archive Slots", result);
|
||||
SetResult("存档槽位列表", result);
|
||||
}
|
||||
|
||||
private async Task GetArchiveMetaAsync()
|
||||
{
|
||||
var result = await Brisk.Archive.GetMetaAsync(ParseRequiredInt(ArchiveSlotNo, nameof(ArchiveSlotNo)));
|
||||
ArchiveBaseVersion = result == null ? ArchiveBaseVersion : result.Version.ToString();
|
||||
SetResult("Archive Meta", result);
|
||||
SetResult("存档元信息", result);
|
||||
}
|
||||
|
||||
private async Task UploadArchiveAsync()
|
||||
@@ -481,7 +481,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
var bytes = Encoding.UTF8.GetBytes(ArchiveContent ?? string.Empty);
|
||||
var result = await Brisk.Archive.UploadAsync(slotNo, bytes, baseVersion);
|
||||
ArchiveBaseVersion = result == null ? ArchiveBaseVersion : result.Version.ToString();
|
||||
SetResult("Archive Upload", result);
|
||||
SetResult("存档上传结果", result);
|
||||
}
|
||||
|
||||
private async Task DownloadArchiveAsync()
|
||||
@@ -497,49 +497,49 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
{ "text_preview", result.Bytes == null ? string.Empty : Encoding.UTF8.GetString(result.Bytes) }
|
||||
};
|
||||
|
||||
SetResult("Archive Download", output);
|
||||
SetResult("存档下载结果", output);
|
||||
}
|
||||
|
||||
private async Task GetSpaceByPlayerIdAsync()
|
||||
{
|
||||
var result = await Brisk.Space.GetByPlayerIdAsync(SpacePlayerId);
|
||||
SetResult("Space By PlayerId", result);
|
||||
SetResult("按 PlayerId 获取空间", result);
|
||||
}
|
||||
|
||||
private async Task GetSpaceByLoginAsync()
|
||||
{
|
||||
var result = await Brisk.Space.GetByLoginIdentityAsync(SpaceLoginProvider, SpaceLoginUserId);
|
||||
SetResult("Space By Login", result);
|
||||
SetResult("按登录身份获取空间", result);
|
||||
}
|
||||
|
||||
private async Task GetSpaceStatsByPlayerIdAsync()
|
||||
{
|
||||
var result = await Brisk.Space.GetStatsByPlayerIdAsync(SpacePlayerId);
|
||||
SetResult("Space Stats By PlayerId", result);
|
||||
SetResult("按 PlayerId 获取空间统计", result);
|
||||
}
|
||||
|
||||
private async Task GetSpaceStatsByLoginAsync()
|
||||
{
|
||||
var result = await Brisk.Space.GetStatsByLoginIdentityAsync(SpaceLoginProvider, SpaceLoginUserId);
|
||||
SetResult("Space Stats By Login", result);
|
||||
SetResult("按登录身份获取空间统计", result);
|
||||
}
|
||||
|
||||
private async Task LikeByPlayerIdAsync()
|
||||
{
|
||||
await Brisk.Space.LikeByPlayerIdAsync(SpacePlayerId);
|
||||
SetResult("Like By PlayerId", new Dictionary<string, object> { { "player_id", SpacePlayerId } });
|
||||
SetResult("按 PlayerId 点赞结果", new Dictionary<string, object> { { "player_id", SpacePlayerId } });
|
||||
}
|
||||
|
||||
private async Task UnlikeByPlayerIdAsync()
|
||||
{
|
||||
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()
|
||||
{
|
||||
await Brisk.Space.LikeByLoginIdentityAsync(SpaceLoginProvider, SpaceLoginUserId);
|
||||
SetResult("Like By Login", new Dictionary<string, object>
|
||||
SetResult("按登录身份点赞结果", new Dictionary<string, object>
|
||||
{
|
||||
{ "login_provider", SpaceLoginProvider },
|
||||
{ "login_user_id", SpaceLoginUserId }
|
||||
@@ -549,7 +549,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
private async Task UnlikeByLoginAsync()
|
||||
{
|
||||
await Brisk.Space.UnlikeByLoginIdentityAsync(SpaceLoginProvider, SpaceLoginUserId);
|
||||
SetResult("Unlike By Login", new Dictionary<string, object>
|
||||
SetResult("按登录身份取消点赞结果", new Dictionary<string, object>
|
||||
{
|
||||
{ "login_provider", SpaceLoginProvider },
|
||||
{ "login_user_id", SpaceLoginUserId }
|
||||
@@ -567,13 +567,13 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
};
|
||||
|
||||
await Brisk.Space.UpdateMyAsync(payload);
|
||||
SetResult("Update My Space", payload);
|
||||
SetResult("更新我的空间结果", payload);
|
||||
}
|
||||
|
||||
private async Task GetMyVisitsAsync()
|
||||
{
|
||||
var result = await Brisk.Space.GetMyVisitsAsync();
|
||||
SetResult("My Space Visits", result);
|
||||
SetResult("我的访客列表", result);
|
||||
}
|
||||
|
||||
private async Task RunSmokeFlowAsync()
|
||||
@@ -619,21 +619,21 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
{
|
||||
_isBusy = true;
|
||||
_busyAction = actionName;
|
||||
_statusText = "Running: " + actionName;
|
||||
_statusText = "执行中: " + actionName;
|
||||
_lastErrorText = string.Empty;
|
||||
Log("Start: " + actionName);
|
||||
Log("开始执行: " + actionName);
|
||||
|
||||
try
|
||||
{
|
||||
await action();
|
||||
_statusText = "Success: " + actionName;
|
||||
Log("Success: " + actionName);
|
||||
_statusText = "执行成功: " + actionName;
|
||||
Log("执行成功: " + actionName);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
_statusText = "Failed: " + actionName;
|
||||
_statusText = "执行失败: " + actionName;
|
||||
_lastErrorText = FormatException(exception);
|
||||
Log("Failed: " + actionName + " | " + exception.GetType().Name + " | " + exception.Message);
|
||||
Log("执行失败: " + actionName + " | " + exception.GetType().Name + " | " + exception.Message);
|
||||
Debug.LogException(exception, this);
|
||||
}
|
||||
finally
|
||||
@@ -693,33 +693,33 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
|
||||
private void HandleInitialized()
|
||||
{
|
||||
Log("Event: OnInitialized");
|
||||
Log("事件: 初始化完成");
|
||||
}
|
||||
|
||||
private void HandleLoggedIn()
|
||||
{
|
||||
Log("Event: OnLoggedIn");
|
||||
Log("事件: 登录完成");
|
||||
ApplyCurrentIdentityToSpace();
|
||||
}
|
||||
|
||||
private void HandleLoggedOut()
|
||||
{
|
||||
Log("Event: OnLoggedOut");
|
||||
Log("事件: 登出完成");
|
||||
}
|
||||
|
||||
private void HandleAuthExpired(BriskAuthExpiredException exception)
|
||||
{
|
||||
Log("Event: OnAuthExpired | " + exception.Message);
|
||||
Log("事件: 登录态失效 | " + exception.Message);
|
||||
}
|
||||
|
||||
private void HandleBlockingError(BriskBlockingException exception)
|
||||
{
|
||||
Log("Event: OnBlockingError | " + exception.Message);
|
||||
Log("事件: 严重阻断错误 | " + exception.Message);
|
||||
}
|
||||
|
||||
private void HandleExitRequested()
|
||||
{
|
||||
Log("Exit requested by Brisk blocking flow.");
|
||||
Log("Brisk 阻断流程请求退出。");
|
||||
}
|
||||
|
||||
private void Log(string message)
|
||||
@@ -738,7 +738,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
{
|
||||
if (!int.TryParse(value, out var result))
|
||||
{
|
||||
throw new InvalidOperationException(fieldName + " must be a valid integer.");
|
||||
throw new InvalidOperationException(fieldName + " 必须是合法整数。");
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -748,7 +748,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
{
|
||||
if (!long.TryParse(value, out var result))
|
||||
{
|
||||
throw new InvalidOperationException(fieldName + " must be a valid integer.");
|
||||
throw new InvalidOperationException(fieldName + " 必须是合法整数。");
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -773,7 +773,7 @@ public sealed class BriskQuickStartSample : MonoBehaviour
|
||||
{
|
||||
if (exception == null)
|
||||
{
|
||||
return "Unknown error.";
|
||||
return "未知错误。";
|
||||
}
|
||||
|
||||
var builder = new StringBuilder();
|
||||
|
||||
@@ -257,7 +257,7 @@ MonoBehaviour:
|
||||
LoginProvider: tap
|
||||
LoginUserId: tap_user_10001
|
||||
LoginCode:
|
||||
Nickname: Unity Sample User
|
||||
Nickname: Unity示例玩家
|
||||
AvatarUrl:
|
||||
RankKey: season-score
|
||||
SubmitScoreValue: 128
|
||||
@@ -267,10 +267,10 @@ MonoBehaviour:
|
||||
SeasonHistoryLimit: 20
|
||||
ArchiveSlotNo: 1
|
||||
ArchiveBaseVersion:
|
||||
ArchiveContent: '{"save":1,"coins":128,"hero":"mage"}'
|
||||
ArchiveContent: '{"save":1,"coins":128,"hero":"mage","title":"中文测试存档"}'
|
||||
AnnouncementId:
|
||||
SpacePlayerId:
|
||||
SpaceLoginProvider: tap
|
||||
SpaceLoginUserId: tap_user_10001
|
||||
SpacePayloadText: '{"mood":"ready","title":"hello brisk"}'
|
||||
SpacePayloadText: '{"mood":"ready","title":"你好 Brisk","desc":"这是中文测试空间数据"}'
|
||||
AutoRunOnStart: 0
|
||||
|
||||
Reference in New Issue
Block a user