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

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