fix: grow animation spawning at correct positions
This commit is contained in:
parent
a06779c5c1
commit
f0af2a5a07
3 changed files with 19 additions and 5 deletions
|
@ -10,6 +10,8 @@ namespace View.Scene {
|
|||
[SerializeField] private GrowParticle growParticle;
|
||||
[SerializeField] private Transform[] growParticlePositions;
|
||||
|
||||
[SerializeField] private GrowAnimation growAnimation;
|
||||
|
||||
private Score _score;
|
||||
|
||||
private void Awake() {
|
||||
|
@ -22,11 +24,17 @@ namespace View.Scene {
|
|||
|
||||
public void OnInputReceived() {
|
||||
float randomRotation = Random.Range(0, 360);
|
||||
growParticle.Spawn(GetGrowParticlePosition(), Quaternion.Euler(0, 0, randomRotation));
|
||||
if(growAnimation.Growing)
|
||||
growParticle.Spawn(GetGrowParticlePosition(), Quaternion.Euler(0, 0, randomRotation));
|
||||
}
|
||||
|
||||
private Vector3 GetGrowParticlePosition() {
|
||||
float iterationStep = 1f / _score.SpawnRate;
|
||||
bool isLastGrowStep = _score.Value % (_score.GrowIterations * _score.SpawnRate) == 0;
|
||||
|
||||
if(isLastGrowStep)
|
||||
return growParticlePositions[^1].position;
|
||||
|
||||
for (int i = 0; i < growParticlePositions.Length; i++) {
|
||||
if (_score.GrowPercentage < (i + 1) * iterationStep)
|
||||
return growParticlePositions[i].position;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue