| 1234567891011121314151617181920212223242526272829 |
- using TMPro;
- using UnityEngine;
- namespace Olympus
- {
- public sealed class ScoreFloat : MonoBehaviour
- {
- public TextMeshProUGUI label;
- public CanvasGroup group;
- public Vector2 restPosition;
- [System.NonSerialized] public OlympusGame owner;
- public float Age { get; private set; }
- public void Show(int gain)
- {
- Age=0;label.text="<size=55%>CORRECT</size>\n+"+gain;
- ((RectTransform)transform).anchoredPosition=restPosition;
- group.alpha=1;gameObject.SetActive(true);
- }
- void Update(){Advance(Mathf.Min(Time.unscaledDeltaTime,.1f));}
- public void Advance(float delta)
- {
- if(!gameObject.activeSelf || (owner && owner.EffectsPaused))return;
- Age+=Mathf.Max(0,delta);
- ((RectTransform)transform).anchoredPosition=restPosition+Vector2.up*(38*Mathf.Min(Age,1.2f));
- group.alpha=1-Mathf.Clamp01((Age-.45f)/.75f);
- if(Age>=1.2f)gameObject.SetActive(false);
- }
- }
- }
|