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); + }); }); }); }