コーン株収穫アニメーション修正

This commit is contained in:
kimura 2021-08-04 12:30:40 +09:00
parent 4e3a1646fd
commit f53a908a60
1 changed files with 17 additions and 9 deletions

View File

@ -26,6 +26,8 @@ public class CornField : MonoBehaviour
private readonly List<PlantLine> availableLines = new List<PlantLine>(); private readonly List<PlantLine> availableLines = new List<PlantLine>();
private static readonly int maxPeriod = 60; private static readonly int maxPeriod = 60;
private static readonly int minPeriod = 45; private static readonly int minPeriod = 45;
private static readonly int harvestedFrameInterval = 3;
private static readonly float harvestedDistance = .2f;
private readonly CompositeDisposable compositeDisposable = new CompositeDisposable(); private readonly CompositeDisposable compositeDisposable = new CompositeDisposable();
// Start is called before the first frame update // Start is called before the first frame update
@ -100,19 +102,25 @@ public class CornField : MonoBehaviour
var harvestCount = GetHarvestCount(lineData.Seedlings[index].level); var harvestCount = GetHarvestCount(lineData.Seedlings[index].level);
var harvestedCorn = GetHarvestedCornCount(gameData.MachineLevel); var harvestedCorn = GetHarvestedCornCount(gameData.MachineLevel);
gameData.cornSeed += harvestedCorn * harvestCount; gameData.cornSeed += harvestedCorn * harvestCount;
var seedlingTransform = seedling.transform;
for (int j = 0; j < harvestCount; j++) for (int j = 0; j < harvestCount; j++)
{ {
var harvestAnimation = Instantiate(harvestPrefab, seedling.transform); var pos = seedlingTransform.position + Vector3.right * (j - 1) * (harvestCount - 1) * harvestedDistance + Vector3.forward * (j - 1);
this.CallWaitForSeconds(.5f, () => // 複数株
this.CallWaitForFrame(harvestedFrameInterval * j, () =>
{ {
var beginPos = harvestAnimation.transform.position; var harvestAnimation = Instantiate(harvestPrefab, pos, Quaternion.identity, seedlingTransform);
this.CallLerp(.4f, f => this.CallWaitForSeconds(.5f, () =>
{ {
harvestAnimation.transform.position = Vector3.Lerp(beginPos, harvestInsertPosition.position, f.EaseInQuadratic()); var beginPos = harvestAnimation.transform.position;
}, () => this.CallLerp(.4f, f =>
{ {
cornHarvester.AddCount(harvestedCorn); harvestAnimation.transform.position = Vector3.Lerp(beginPos, harvestInsertPosition.position, f.EaseInQuadratic());
Destroy(harvestAnimation); }, () =>
{
cornHarvester.AddCount(harvestedCorn);
Destroy(harvestAnimation);
});
}); });
}); });
} }