- 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]>
97 lines
3.3 KiB
C#
97 lines
3.3 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
// 開場:STHKM3 → 戴上耳機 → 閃爍警告;點擊跳到下一張
|
|
// 第一次開啟且還沒有儲存權限時,結束後詢問是否使用手機根目錄的 Rhyculator/package
|
|
public class IntroPage : Page
|
|
{
|
|
private static readonly float[] Durations = { 1.885f, 1.846f, 1.846f };
|
|
|
|
public override bool UsesGrid => false;
|
|
|
|
private readonly List<GameObject> cards = new List<GameObject>();
|
|
private int index = -1;
|
|
private float nextAt;
|
|
|
|
public override void Enter()
|
|
{
|
|
cards.Add(ImageCard("Start_1", null));
|
|
cards.Add(ImageCard("Start_2", "戴上耳機以獲得最佳體驗"));
|
|
cards.Add(TextCard("本遊戲包含大量閃爍特效\n請斟酌遊玩"));
|
|
Next();
|
|
}
|
|
|
|
GameObject ImageCard(string sprite, string caption)
|
|
{
|
|
var card = Ui.Stretch(Ui.Rect(Top, sprite));
|
|
var img = Ui.Image(card, Sprites.Get(sprite), Color.white);
|
|
img.preserveAspect = true;
|
|
Ui.Place(img.rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0, caption != null ? 120 : 0), new Vector2(1080, 720));
|
|
if (caption != null)
|
|
{
|
|
var t = Ui.Label(card, caption, 64, Color.white);
|
|
Ui.Place(t.rectTransform, new Vector2(0.5f, 0.5f), new Vector2(0, -220), new Vector2(1000, 120));
|
|
}
|
|
card.gameObject.SetActive(false);
|
|
return card.gameObject;
|
|
}
|
|
|
|
GameObject TextCard(string text)
|
|
{
|
|
var t = Ui.Label(Top, text, 64, Color.white);
|
|
t.lineSpacing = 1.3f;
|
|
Ui.Stretch(t.rectTransform, 40, 0, 40, 0);
|
|
t.gameObject.SetActive(false);
|
|
return t.gameObject;
|
|
}
|
|
|
|
void Next()
|
|
{
|
|
if (index >= 0) cards[index].SetActive(false);
|
|
index++;
|
|
if (index >= cards.Count)
|
|
{
|
|
Finish();
|
|
return;
|
|
}
|
|
cards[index].SetActive(true);
|
|
nextAt = -1; // 從第一個畫出來的幀開始計時(剛啟動的前幾幀很慢)
|
|
}
|
|
|
|
public override void Tick(List<GridTouch> touches)
|
|
{
|
|
if (index >= cards.Count) return;
|
|
if (nextAt < 0)
|
|
{
|
|
if (Time.unscaledDeltaTime < 0.1f) nextAt = Time.unscaledTime + Durations[index];
|
|
return;
|
|
}
|
|
if (Time.unscaledTime >= nextAt || GridInput.AnyNewTap()) Next();
|
|
}
|
|
|
|
public override void Back() => Next();
|
|
|
|
void Finish()
|
|
{
|
|
if (!PackStorage.SupportsShared || PackStorage.HasSharedAccess() || PlayerPrefs.GetInt(Prefs.StorageAsked, 0) == 1)
|
|
{
|
|
App.Go(new MainPage());
|
|
return;
|
|
}
|
|
|
|
PlayerPrefs.SetInt(Prefs.StorageAsked, 1);
|
|
var d = new Dialog(App.Overlay, "曲包資料夾",
|
|
"允許「所有檔案存取權」後,曲包會放在手機的\n<color=#FF66C4>Rhyculator/package</color>\n" +
|
|
"接上電腦或用檔案管理員就能直接放入 .zip 曲包,像插上隨身碟一樣。\n\n" +
|
|
"不允許也可以玩,曲包會放在 app 自己的資料夾。之後可在設定裡更改。");
|
|
d.cancellable = false;
|
|
d.AddClose("先不要", () => App.Go(new MainPage()));
|
|
d.AddClose("前往授權", () =>
|
|
{
|
|
PackStorage.RequestSharedAccess();
|
|
App.Go(new MainPage());
|
|
}, primary: true);
|
|
}
|
|
}
|