parent
							
								
									254cbd1c25
								
							
						
					
					
						commit
						25300e964a
					
				|  | @ -7,8 +7,8 @@ public class HeartAnimation : MonoBehaviour | ||||||
|     [SerializeField] private GameObject smallHeart; |     [SerializeField] private GameObject smallHeart; | ||||||
|     [SerializeField] private Transform target; |     [SerializeField] private Transform target; | ||||||
|     private float animationDelay = .3f; |     private float animationDelay = .3f; | ||||||
|     private float animationDuration = .8f; |     private float animationDuration = .5f; | ||||||
|     private float heartToMeterDuration = .5f; |     private float heartToMeterDuration = .4f; | ||||||
|     public void GetHeart(Action callback = null) |     public void GetHeart(Action callback = null) | ||||||
|     { |     { | ||||||
|         smallHeart.SetActive(false); |         smallHeart.SetActive(false); | ||||||
|  | @ -26,7 +26,7 @@ public class HeartAnimation : MonoBehaviour | ||||||
|                 }, () => |                 }, () => | ||||||
|                 { |                 { | ||||||
|                     smallHeart.SetActive(true); |                     smallHeart.SetActive(true); | ||||||
|                     this.CallWaitForSeconds(1f, () => |                     this.CallWaitForSeconds(.5f, () => | ||||||
|                     { |                     { | ||||||
|                         callback?.Invoke(); |                         callback?.Invoke(); | ||||||
|                         Destroy(bigHeart); |                         Destroy(bigHeart); | ||||||
|  |  | ||||||
|  | @ -11,6 +11,7 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter> | ||||||
| 
 | 
 | ||||||
|     private List<int> levelList = new List<int>(); |     private List<int> levelList = new List<int>(); | ||||||
|     private int currentHeartCount; |     private int currentHeartCount; | ||||||
|  |     private float tmpHeart; | ||||||
|     private Coroutine coroutine; |     private Coroutine coroutine; | ||||||
| 
 | 
 | ||||||
|     public void Initialize(List<int> list) |     public void Initialize(List<int> list) | ||||||
|  | @ -20,7 +21,9 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter> | ||||||
|      |      | ||||||
|     public void SetHeart(int heartCount) |     public void SetHeart(int heartCount) | ||||||
|     { |     { | ||||||
|  |         Debug.Log($"{currentHeartCount}, {tmpHeart}"); | ||||||
|         currentHeartCount = heartCount; |         currentHeartCount = heartCount; | ||||||
|  |         tmpHeart = heartCount; | ||||||
|         SetView(currentHeartCount); |         SetView(currentHeartCount); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -40,7 +43,6 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter> | ||||||
|     { |     { | ||||||
|          |          | ||||||
|         slider.value = (heartCount - levelList[index - 1]) / (levelList[index] - levelList[index - 1]); |         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) |     private int GetNextLevel(int heartCount) | ||||||
|  | @ -56,15 +58,15 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter> | ||||||
|     public void AddHeart(int value) |     public void AddHeart(int value) | ||||||
|     { |     { | ||||||
|         this.SafeStopCoroutine(coroutine); |         this.SafeStopCoroutine(coroutine); | ||||||
|         var tmpHeart = currentHeartCount; |  | ||||||
|         currentHeartCount += value; |         currentHeartCount += value; | ||||||
|         coroutine = this.CallLerp(1f, f => |         coroutine = this.CallWaitForSeconds(1f, () => | ||||||
|         { |  | ||||||
|             var heart = tmpHeart + Mathf.Lerp(0, value, f); |  | ||||||
|             SetView(heart); |  | ||||||
|         }, () => |  | ||||||
|         { |         { | ||||||
|             SetHeart(currentHeartCount); |             SetHeart(currentHeartCount); | ||||||
|         }); |         }); | ||||||
|  |         this.CallLerp(1f, f => | ||||||
|  |         { | ||||||
|  |             tmpHeart += value * Time.deltaTime; | ||||||
|  |             SetView(Mathf.Min(currentHeartCount, tmpHeart)); | ||||||
|  |         }); | ||||||
|     } |     } | ||||||
| } | } | ||||||
		Loading…
	
		Reference in New Issue