feat: delay animation after spawning flower

This commit is contained in:
Gerard Gascón 2024-04-22 20:00:29 +02:00
parent 3522a015f6
commit bab2db51e5
2 changed files with 15 additions and 7 deletions

View file

@ -1,4 +1,5 @@
using System;
using System.Collections;
using Domain;
using FMODUnity;
using Presenter;
@ -20,7 +21,7 @@ namespace View.Scene {
private SpawnRose _spawnRose;
private bool _firstUpdate = true;
public bool Growing { private set; get; } = true;
public bool Growing { private set; get; }
private void Start() {
_score = FindObjectOfType<Dependencies>().Score;
@ -41,8 +42,7 @@ namespace View.Scene {
if (animationName == "Rosa_End") {
_spawnRose.Execute();
animator.ChangeAnimation(startAnimation);
animator.PlayUntil(1f);
StartCoroutine(RestartCycle());
}
if (animationName == "Rosa_Start") {
@ -52,6 +52,14 @@ namespace View.Scene {
}
}
IEnumerator RestartCycle() {
animator.Renderer.enabled = false;
yield return new WaitForSeconds(2f);
animator.Renderer.enabled = true;
animator.ChangeAnimation(startAnimation);
animator.PlayUntil(1f);
}
public void GrowStep() {
if (animator.CurrentAnimation == "Rosa_Grow") {
if (IsLastGrowState())