parent
254cbd1c25
commit
25300e964a
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter>
|
|||
|
||||
private List<int> levelList = new List<int>();
|
||||
private int currentHeartCount;
|
||||
private float tmpHeart;
|
||||
private Coroutine coroutine;
|
||||
|
||||
public void Initialize(List<int> list)
|
||||
|
|
@ -20,7 +21,9 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter>
|
|||
|
||||
public void SetHeart(int heartCount)
|
||||
{
|
||||
Debug.Log($"{currentHeartCount}, {tmpHeart}");
|
||||
currentHeartCount = heartCount;
|
||||
tmpHeart = heartCount;
|
||||
SetView(currentHeartCount);
|
||||
}
|
||||
|
||||
|
|
@ -40,7 +43,6 @@ public class HeartMeter : SingletonMonoBehaviour<HeartMeter>
|
|||
{
|
||||
|
||||
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<HeartMeter>
|
|||
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));
|
||||
});
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue