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 cards = new List(); 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 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, "曲包資料夾", "允許「所有檔案存取權」後,曲包會放在手機的\nRhyculator/package\n" + "接上電腦或用檔案管理員就能直接放入 .zip 曲包,像插上隨身碟一樣。\n\n" + "不允許也可以玩,曲包會放在 app 自己的資料夾。之後可在設定裡更改。"); d.cancellable = false; d.AddClose("先不要", () => App.Go(new MainPage())); d.AddClose("前往授權", () => { PackStorage.RequestSharedAccess(); App.Go(new MainPage()); }, primary: true); } }