- One empty scene; App builds the canvas, safe-area layout and a shared 5x6 Grid in code. Pages (Intro, Main, Choose, Play, Account, Settings) replace 5 scenes, 5 prefabs and the per-cell spawner/display components. - Packs: the game reads Rhyculator/package/ (with All files access) or the app folder, like a plugged-in USB stick. Zips stay where they are and are extracted to a cache keyed by name/size/mtime; folders are read directly. Scans run every second on a background thread. Old songs/ imports and inbox zips are migrated automatically. - Download packs by 8-char code from the new pack website, or via rhyculator://pack/<code> links; opened/shared zips go into the package folder. - Play: pause/resume/retry, auto-pause on background, combo and progress bar; judging and scoring unchanged. Choose page fits 9:16 screens; empty state, pack delete. Android back key handled everywhere. - Slimming: removed TextMesh Pro, unused 2D/Timeline/VisualScripting/etc. packages and modules, scene template, unused sprites; menu theme wav (20MB) -> ogg (2.3MB). Build profile replaced by explicit settings in BuildAndroid. - Tests: PackLibrary/PackReader/migration/serializer tests (39 passing). Co-Authored-By: Claude Opus 5.5 <[email protected]>
37 lines
1.6 KiB
C#
37 lines
1.6 KiB
C#
using UnityEngine;
|
|
|
|
// 所有 PlayerPrefs 的鍵集中在這裡(沿用舊版的鍵名,更新後登入狀態與設定不會消失)
|
|
public static class Prefs
|
|
{
|
|
public const string Uid = "UID";
|
|
public const string Token = "Token";
|
|
public const string LegacyPassword = "Password"; // 舊版存的密碼,登入成功後刪除
|
|
public const string Name = "Name";
|
|
public const string Email = "Email";
|
|
public const string AccountType = "Type";
|
|
public const string CreateTime = "CreateTime";
|
|
public const string EmailVerified = "EmailVerified";
|
|
|
|
public const string Song = "NowPlayingSong";
|
|
public const string Level = "NowPlayingLevel";
|
|
public const string AudioOffsetMs = "AudioOffsetMs";
|
|
public const string VideoBackground = "VideoBackground";
|
|
public const string StorageAsked = "StorageAsked";
|
|
|
|
public static int UserId => PlayerPrefs.GetInt(Uid, 0);
|
|
public static bool LoggedIn => UserId != 0 && (PlayerPrefs.HasKey(Token) || PlayerPrefs.HasKey(LegacyPassword));
|
|
|
|
// UID 顯示格式:帳號類型字元 + x + 8 位十六進位
|
|
public static string UidText()
|
|
{
|
|
int uid = UserId;
|
|
string type = PlayerPrefs.GetString(AccountType, "");
|
|
if (uid == 0 || type == "") return "0x00000000";
|
|
char c = type switch { "R" => '0', "A" => 'a', "B" => 'b', "D" => 'f', _ => '?' };
|
|
return $"{c}x{uid:X8}";
|
|
}
|
|
|
|
public static void SetBool(string key, bool value) => PlayerPrefs.SetInt(key, value ? 1 : 0);
|
|
public static bool GetBool(string key, bool fallback) => PlayerPrefs.GetInt(key, fallback ? 1 : 0) == 1;
|
|
}
|