using System.Collections; using UnityEngine; using UnityEngine.UI; namespace DiamondArrow { public sealed class VictoryView : MonoBehaviour { public RawImage portrait; public Text playerName; public Text level; public Text chapter; public RawImage[] stars; public Text performance; public Text total; public Text clearBonus; public Text firstClearBonus; public Text timeBonus; public Button next; public Button home; public void ShowReward(ClearReward reward) { total.text = "+" + reward.Total; clearBonus.text = "+" + reward.basic; firstClearBonus.text = "+" + reward.first; timeBonus.text = "+" + reward.time; for (int i = 0; i < stars.Length; i++) stars[i].color = i < reward.stars ? Color.white : new Color(.48f, .37f, .55f, .48f); StartCoroutine(RevealStars(reward.stars)); } IEnumerator RevealStars(int earned) { const float duration = .32f, stagger = .09f; for (float elapsed = 0; elapsed < duration + stagger * (earned - 1); elapsed += Time.unscaledDeltaTime) { for (int i = 0; i < earned; i++) { float t = Mathf.Clamp01((elapsed - i * stagger) / duration); float scale = Mathf.SmoothStep(.64f, 1f, t) + .17f * Mathf.Sin(t * Mathf.PI); stars[i].rectTransform.localScale = Vector3.one * scale; } yield return null; } for (int i = 0; i < earned; i++) stars[i].rectTransform.localScale = Vector3.one; } } }