123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using UnityEngine;
- using System.Collections;
- using UnityEngine.UI;
- using DG.Tweening;
- public class StarAchieved : MonoBehaviour
- {
- public Image full;
- public SoundEvent starSound;
- Vector3 _originalScale;
- const float INIT_DELAY = 1;
- const float DELAY_INCREMENT_PER_STAR = 0.25f;
- const float TRANSITION_TIME = 0.5f;
- void Awake()
- {
- _originalScale = full.transform.localScale;
- }
- void OnEnable()
- {
- full.color = new Color(full.color.r, full.color.g, full.color.b, 0);
- }
- public void Animate(int index)
- {
- float delay = INIT_DELAY + index * DELAY_INCREMENT_PER_STAR;
- full.StopAllCoroutines();
- full.color = new Color(full.color.r, full.color.g, full.color.b, 0);
- full.DOFade(1, INIT_DELAY + index * DELAY_INCREMENT_PER_STAR);
- full.transform.localScale = _originalScale*2;
- full.ScaleTo(_originalScale, TRANSITION_TIME, delay, MyTween.Ease.easeInOutBounce);
- SoundManager.Play(starSound);
- }
- void OniTweenUpdateAlpha(float newAlpha)
- {
- full.color = new Color(full.color.r, full.color.g, full.color.b, newAlpha);
- }
- }
|