using UnityEngine; using UnityEngine.UI; namespace Class03 { // 점수 변경을 화면 텍스트에 반영하는 역할만 합니다. public sealed class ScoreView : MonoBehaviour { [SerializeField] private ScoreCounter counter; [SerializeField] private Text scoreText; [SerializeField] private Text statusText; public void Initialize(ScoreCounter source, Text score, Text status) { counter = source; scoreText = score; statusText = status; } private void OnEnable() { if (counter == null) return; counter.Changed += Refresh; Refresh(counter.Score, counter.TargetScore); } private void OnDisable() { if (counter != null) counter.Changed -= Refresh; } private void Refresh(int score, int target) { scoreText.text = $"STARS {score:00} / {target:00}"; statusText.text = score >= target ? "ALL STARS COLLECTED!" : "ROLL. EXPLORE. COLLECT."; } } }