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

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,9 +102,14 @@ 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.CallWaitForFrame(harvestedFrameInterval * j, () =>
{
var harvestAnimation = Instantiate(harvestPrefab, pos, Quaternion.identity, seedlingTransform);
this.CallWaitForSeconds(.5f, () => this.CallWaitForSeconds(.5f, () =>
{ {
var beginPos = harvestAnimation.transform.position; var beginPos = harvestAnimation.transform.position;
@ -115,6 +122,7 @@ public class CornField : MonoBehaviour
Destroy(harvestAnimation); Destroy(harvestAnimation);
}); });
}); });
});
} }
// 新しい苗 // 新しい苗
var newGene = GenerateSeedlingGene(line.FieldLevel); var newGene = GenerateSeedlingGene(line.FieldLevel);