- 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]>
88 lines
3.7 KiB
C#
88 lines
3.7 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
// 結算畫面(以程式建立,不需改動場景)
|
|
public static class ResultOverlay
|
|
{
|
|
public static GameObject Show(PlayResult r, int totalNotes, Font font, string uploadStatus)
|
|
{
|
|
var root = new GameObject("ResultOverlay", typeof(Canvas), typeof(CanvasScaler));
|
|
var canvas = root.GetComponent<Canvas>();
|
|
canvas.renderMode = RenderMode.ScreenSpaceOverlay;
|
|
canvas.sortingOrder = 100;
|
|
var scaler = root.GetComponent<CanvasScaler>();
|
|
scaler.uiScaleMode = CanvasScaler.ScaleMode.ScaleWithScreenSize;
|
|
scaler.referenceResolution = new Vector2(1080, 2400);
|
|
scaler.matchWidthOrHeight = 0f;
|
|
|
|
var bg = NewChild(root.transform, "Background").AddComponent<Image>();
|
|
bg.color = new Color(0f, 0f, 0f, 0.88f);
|
|
Stretch(bg.rectTransform);
|
|
|
|
int hit = r.perfect + r.fast + r.slow + r.bad;
|
|
float acc = totalNotes > 0
|
|
? (r.perfect + 0.75f * (r.fast + r.slow) + 0.25f * r.bad) / totalNotes * 100f
|
|
: 0f;
|
|
|
|
AddText(root.transform, font, "RESULT", 72, new Color(1f, 0.42f, 0.8f), 600);
|
|
AddText(root.transform, font, r.score.ToString(), 140, Color.white, 420);
|
|
AddText(root.transform, font, $"準確率 {acc:0.00}% 最大連擊 {r.maxCombo}", 44, new Color(0.85f, 0.85f, 0.85f), 280);
|
|
|
|
// 兩欄:判定名稱靠右、次數靠左(比例字型無法用空白對齊)
|
|
string names =
|
|
"<color=#6EB4FF>Perfect</color>\n<color=#7CD67C>Fast</color>\n<color=#FFA64D>Slow</color>\n" +
|
|
"<color=#FF5050>Bad</color>\n<color=#888888>Miss</color>";
|
|
string counts = $"{r.perfect}\n{r.fast}\n{r.slow}\n{r.bad}\n{r.miss}";
|
|
AddColumn(root.transform, font, names, TextAnchor.MiddleRight, -40);
|
|
AddColumn(root.transform, font, counts, TextAnchor.MiddleLeft, 40);
|
|
|
|
AddText(root.transform, font, uploadStatus, 36, new Color(0.6f, 0.6f, 0.6f), -330);
|
|
AddText(root.transform, font, "點擊任意處繼續", 44, new Color(0.85f, 0.85f, 0.85f), -520);
|
|
return root;
|
|
}
|
|
|
|
private static void AddColumn(Transform parent, Font font, string content, TextAnchor align, float x)
|
|
{
|
|
var text = AddText(parent, font, content, 56, Color.white, 0);
|
|
text.supportRichText = true;
|
|
text.alignment = align;
|
|
text.lineSpacing = 1.1f;
|
|
var rt = text.rectTransform;
|
|
rt.pivot = new Vector2(align == TextAnchor.MiddleRight ? 1f : 0f, 0.5f);
|
|
rt.sizeDelta = new Vector2(400, 440);
|
|
rt.anchoredPosition = new Vector2(x, 0);
|
|
}
|
|
|
|
private static GameObject NewChild(Transform parent, string name)
|
|
{
|
|
var go = new GameObject(name, typeof(RectTransform));
|
|
go.transform.SetParent(parent, false);
|
|
return go;
|
|
}
|
|
|
|
private static void Stretch(RectTransform rt)
|
|
{
|
|
rt.anchorMin = Vector2.zero;
|
|
rt.anchorMax = Vector2.one;
|
|
rt.offsetMin = rt.offsetMax = Vector2.zero;
|
|
}
|
|
|
|
private static Text AddText(Transform parent, Font font, string content, int size, Color color, float y)
|
|
{
|
|
var text = NewChild(parent, "Text").AddComponent<Text>();
|
|
text.font = font;
|
|
text.text = content;
|
|
text.fontSize = size;
|
|
text.color = color;
|
|
text.alignment = TextAnchor.MiddleCenter;
|
|
text.horizontalOverflow = HorizontalWrapMode.Overflow;
|
|
text.verticalOverflow = VerticalWrapMode.Overflow;
|
|
text.raycastTarget = false;
|
|
var rt = text.rectTransform;
|
|
rt.anchorMin = rt.anchorMax = new Vector2(0.5f, 0.5f);
|
|
rt.sizeDelta = new Vector2(1000, size * 1.5f);
|
|
rt.anchoredPosition = new Vector2(0, y);
|
|
return text;
|
|
}
|
|
}
|