diff --git a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornHarvester.cs b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornHarvester.cs index 41bac280..6b056feb 100644 --- a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornHarvester.cs +++ b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornHarvester.cs @@ -16,8 +16,11 @@ public class CornHarvester : MonoBehaviour [SerializeField] private GameObject harvestedSpawnTarget; [SerializeField] private float thrust = 100f; [SerializeField] private Transform machineTarget; + // 収穫演出で出るコーンの数を制限 + [SerializeField] private float cullCornRate = .8f; + [SerializeField] private int firstCornLimit = 200; + [SerializeField] private int secondCornLimit = 300; private Animator machineAnimator; - private int maxCorn = 100; // 収穫演出で出るコーンの数を制限 private int runningCount; private readonly ReactiveProperty count = new ReactiveProperty(0); @@ -35,7 +38,7 @@ public class CornHarvester : MonoBehaviour { machineAnimator?.SetTrigger(PutOut); runningCount++; - StartCoroutine(Harvested(Mathf.Min(maxCorn, x.Current - x.Previous), (list) => + StartCoroutine(Harvested(x.Current - x.Previous, (list) => { runningCount--; if (runningCount == 0) @@ -59,6 +62,12 @@ public class CornHarvester : MonoBehaviour for (int i = 0; i < cnt; i++) { VibrationManager.Instance.PlayVibrationOnce(); + var cornCount = harvestedSpawnTransform.childCount; + if (cornCount > secondCornLimit || cornCount > firstCornLimit && Random.value <= cullCornRate) + { + yield return null; + continue; + } var corn = Instantiate(harvestedPrefab, harvestedSpawnTransform.position, Quaternion.identity, harvestedSpawnTransform); corn.GetComponent().AddForce(new Vector2(Random.Range(-0.3f, 0.3f), -1).normalized * thrust, ForceMode2D.Impulse); finishedList.Add(corn.GetComponent());