From f53a908a605e973184553e787d475d34a4902279 Mon Sep 17 00:00:00 2001 From: kimura Date: Wed, 4 Aug 2021 12:30:40 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=B3=E6=A0=AA=E5=8F=8E?= =?UTF-8?q?=E7=A9=AB=E3=82=A2=E3=83=8B=E3=83=A1=E3=83=BC=E3=82=B7=E3=83=A7?= =?UTF-8?q?=E3=83=B3=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Scenes/CornField/Scripts/CornField.cs | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs index 985c5436..c0f876bf 100644 --- a/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs +++ b/popcorn/Assets/MyGame/Scenes/CornField/Scripts/CornField.cs @@ -26,6 +26,8 @@ public class CornField : MonoBehaviour private readonly List availableLines = new List(); private static readonly int maxPeriod = 60; private static readonly int minPeriod = 45; + private static readonly int harvestedFrameInterval = 3; + private static readonly float harvestedDistance = .2f; private readonly CompositeDisposable compositeDisposable = new CompositeDisposable(); // Start is called before the first frame update @@ -100,19 +102,25 @@ public class CornField : MonoBehaviour var harvestCount = GetHarvestCount(lineData.Seedlings[index].level); var harvestedCorn = GetHarvestedCornCount(gameData.MachineLevel); gameData.cornSeed += harvestedCorn * harvestCount; + var seedlingTransform = seedling.transform; for (int j = 0; j < harvestCount; j++) { - var harvestAnimation = Instantiate(harvestPrefab, seedling.transform); - this.CallWaitForSeconds(.5f, () => + var pos = seedlingTransform.position + Vector3.right * (j - 1) * (harvestCount - 1) * harvestedDistance + Vector3.forward * (j - 1); + // 複数株 + this.CallWaitForFrame(harvestedFrameInterval * j, () => { - var beginPos = harvestAnimation.transform.position; - this.CallLerp(.4f, f => + var harvestAnimation = Instantiate(harvestPrefab, pos, Quaternion.identity, seedlingTransform); + this.CallWaitForSeconds(.5f, () => { - harvestAnimation.transform.position = Vector3.Lerp(beginPos, harvestInsertPosition.position, f.EaseInQuadratic()); - }, () => - { - cornHarvester.AddCount(harvestedCorn); - Destroy(harvestAnimation); + var beginPos = harvestAnimation.transform.position; + this.CallLerp(.4f, f => + { + harvestAnimation.transform.position = Vector3.Lerp(beginPos, harvestInsertPosition.position, f.EaseInQuadratic()); + }, () => + { + cornHarvester.AddCount(harvestedCorn); + Destroy(harvestAnimation); + }); }); }); }