収穫時のコーン表示制限を追加
This commit is contained in:
parent
91fa8101f4
commit
39a1762612
|
|
@ -16,8 +16,11 @@ public class CornHarvester : MonoBehaviour
|
||||||
[SerializeField] private GameObject harvestedSpawnTarget;
|
[SerializeField] private GameObject harvestedSpawnTarget;
|
||||||
[SerializeField] private float thrust = 100f;
|
[SerializeField] private float thrust = 100f;
|
||||||
[SerializeField] private Transform machineTarget;
|
[SerializeField] private Transform machineTarget;
|
||||||
|
// 収穫演出で出るコーンの数を制限
|
||||||
|
[SerializeField] private float cullCornRate = .8f;
|
||||||
|
[SerializeField] private int firstCornLimit = 200;
|
||||||
|
[SerializeField] private int secondCornLimit = 300;
|
||||||
private Animator machineAnimator;
|
private Animator machineAnimator;
|
||||||
private int maxCorn = 100; // 収穫演出で出るコーンの数を制限
|
|
||||||
private int runningCount;
|
private int runningCount;
|
||||||
|
|
||||||
private readonly ReactiveProperty<int> count = new ReactiveProperty<int>(0);
|
private readonly ReactiveProperty<int> count = new ReactiveProperty<int>(0);
|
||||||
|
|
@ -35,7 +38,7 @@ public class CornHarvester : MonoBehaviour
|
||||||
{
|
{
|
||||||
machineAnimator?.SetTrigger(PutOut);
|
machineAnimator?.SetTrigger(PutOut);
|
||||||
runningCount++;
|
runningCount++;
|
||||||
StartCoroutine(Harvested(Mathf.Min(maxCorn, x.Current - x.Previous), (list) =>
|
StartCoroutine(Harvested(x.Current - x.Previous, (list) =>
|
||||||
{
|
{
|
||||||
runningCount--;
|
runningCount--;
|
||||||
if (runningCount == 0)
|
if (runningCount == 0)
|
||||||
|
|
@ -59,6 +62,12 @@ public class CornHarvester : MonoBehaviour
|
||||||
for (int i = 0; i < cnt; i++)
|
for (int i = 0; i < cnt; i++)
|
||||||
{
|
{
|
||||||
VibrationManager.Instance.PlayVibrationOnce();
|
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);
|
var corn = Instantiate(harvestedPrefab, harvestedSpawnTransform.position, Quaternion.identity, harvestedSpawnTransform);
|
||||||
corn.GetComponent<Rigidbody2D>().AddForce(new Vector2(Random.Range(-0.3f, 0.3f), -1).normalized * thrust, ForceMode2D.Impulse);
|
corn.GetComponent<Rigidbody2D>().AddForce(new Vector2(Random.Range(-0.3f, 0.3f), -1).normalized * thrust, ForceMode2D.Impulse);
|
||||||
finishedList.Add(corn.GetComponent<Collider2D>());
|
finishedList.Add(corn.GetComponent<Collider2D>());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue