From 39a176261213a63029e9964f4fcc1aaf39a4f8f9 Mon Sep 17 00:00:00 2001 From: kimura Date: Tue, 19 Oct 2021 19:50:48 +0900 Subject: [PATCH] =?UTF-8?q?=E5=8F=8E=E7=A9=AB=E6=99=82=E3=81=AE=E3=82=B3?= =?UTF-8?q?=E3=83=BC=E3=83=B3=E8=A1=A8=E7=A4=BA=E5=88=B6=E9=99=90=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/CornField/Scripts/CornHarvester.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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());