演出負荷調整

This commit is contained in:
kimura 2021-07-30 18:38:21 +09:00
parent a2ddc0b512
commit 278e1b927a
2 changed files with 7 additions and 3 deletions

View File

@ -4,7 +4,6 @@ public class Basket : MonoBehaviour
{
private void OnTriggerExit2D(Collider2D other)
{
Debug.Log("exit");
Destroy(other.gameObject, 2f);
}
}

View File

@ -12,6 +12,7 @@ public class CornHarvester : MonoBehaviour
[SerializeField] private GameObject harvestedPrefab;
[SerializeField] private float thrust = 100f;
private float duration = .5f;
private int maxCorn = 100; // 収穫演出で出るコーンの数を制限
private string counterFormat = "{0}";
private Coroutine animationCoroutine;
@ -21,14 +22,18 @@ public class CornHarvester : MonoBehaviour
{
count.AddTo(this);
cornCounter.text = "0";
count.BatchFrame().Select(x => x.Sum()).Pairwise().Subscribe(x =>
count
.BatchFrame()
.Select(x => x.Last())
.Pairwise()
.Subscribe(x =>
{
this.SafeStopCoroutine(animationCoroutine);
animationCoroutine = this.CallLerpSmooth(duration, lerp => {
cornCounter.text = string.Format(counterFormat, (int)Mathf.Lerp(x.Previous, x.Current, lerp));
});
StartCoroutine(Harvested(x.Current - x.Previous));
StartCoroutine(Harvested(Mathf.Min(maxCorn, x.Current - x.Previous)));
}).AddTo(this);
}