diff --git a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/HeartAnimation.cs b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/HeartAnimation.cs index bdcf79e7..0d8a3a7d 100644 --- a/popcorn/Assets/MyGame/Scenes/marketing/Scripts/HeartAnimation.cs +++ b/popcorn/Assets/MyGame/Scenes/marketing/Scripts/HeartAnimation.cs @@ -7,8 +7,8 @@ public class HeartAnimation : MonoBehaviour [SerializeField] private GameObject smallHeart; [SerializeField] private Transform target; private float animationDelay = .3f; - private float animationDuration = .8f; - private float heartToMeterDuration = .5f; + private float animationDuration = .5f; + private float heartToMeterDuration = .4f; public void GetHeart(Action callback = null) { smallHeart.SetActive(false); @@ -26,7 +26,7 @@ public class HeartAnimation : MonoBehaviour }, () => { smallHeart.SetActive(true); - this.CallWaitForSeconds(1f, () => + this.CallWaitForSeconds(.5f, () => { callback?.Invoke(); Destroy(bigHeart); diff --git a/popcorn/Assets/MyGame/Scripts/HeartMeter.cs b/popcorn/Assets/MyGame/Scripts/HeartMeter.cs index 8a746582..6c911e6c 100644 --- a/popcorn/Assets/MyGame/Scripts/HeartMeter.cs +++ b/popcorn/Assets/MyGame/Scripts/HeartMeter.cs @@ -11,6 +11,7 @@ public class HeartMeter : SingletonMonoBehaviour private List levelList = new List(); private int currentHeartCount; + private float tmpHeart; private Coroutine coroutine; public void Initialize(List list) @@ -20,7 +21,9 @@ public class HeartMeter : SingletonMonoBehaviour public void SetHeart(int heartCount) { + Debug.Log($"{currentHeartCount}, {tmpHeart}"); currentHeartCount = heartCount; + tmpHeart = heartCount; SetView(currentHeartCount); } @@ -40,7 +43,6 @@ public class HeartMeter : SingletonMonoBehaviour { slider.value = (heartCount - levelList[index - 1]) / (levelList[index] - levelList[index - 1]); - // Debug.Log($"heart:{heartCount}, i:{index}, val:{slider.value}"); } private int GetNextLevel(int heartCount) @@ -56,15 +58,15 @@ public class HeartMeter : SingletonMonoBehaviour public void AddHeart(int value) { this.SafeStopCoroutine(coroutine); - var tmpHeart = currentHeartCount; currentHeartCount += value; - coroutine = this.CallLerp(1f, f => - { - var heart = tmpHeart + Mathf.Lerp(0, value, f); - SetView(heart); - }, () => + coroutine = this.CallWaitForSeconds(1f, () => { SetHeart(currentHeartCount); }); + this.CallLerp(1f, f => + { + tmpHeart += value * Time.deltaTime; + SetView(Mathf.Min(currentHeartCount, tmpHeart)); + }); } } \ No newline at end of file