feat: start animation

This commit is contained in:
Gerard Gascón 2024-04-22 19:05:46 +02:00
parent a276096476
commit 3522a015f6
354 changed files with 22842 additions and 5 deletions

View file

@ -10,6 +10,8 @@ namespace View {
[SerializeField] private GameObject rose;
public void SpawnRose() {
SpawnInitialRose();
return;
Vector2 spawnPos = new(
spawnerRegion.position.x + Random.Range(-spawnerRegion.size.x / 2f, spawnerRegion.size.x / 2f),
spawnerRegion.position.y + Random.Range(-spawnerRegion.size.y / 2f, spawnerRegion.size.y / 2f)

View file

@ -11,6 +11,7 @@ namespace View.Scene {
[SerializeField] private Animator animator;
[SerializeField] private Animation growAnimation;
[SerializeField] private Animation endAnimation;
[SerializeField] private Animation startAnimation;
[SerializeField] private EventReference growEvent;
[SerializeField] private EventReference gloomEvent;
@ -25,6 +26,8 @@ namespace View.Scene {
_score = FindObjectOfType<Dependencies>().Score;
_spawnRose = FindObjectOfType<Dependencies>().Spawner;
animator.PlayUntil(1f);
animator.OnAnimationEnd += AnimationEnded;
}
@ -37,8 +40,13 @@ namespace View.Scene {
}
if (animationName == "Rosa_End") {
Growing = true;
_spawnRose.Execute();
animator.ChangeAnimation(startAnimation);
animator.PlayUntil(1f);
}
if (animationName == "Rosa_Start") {
Growing = true;
animator.ChangeAnimation(growAnimation);
animator.PlayUntil(_score.GrowPercentage);
}