feat: delay animation after spawning flower
This commit is contained in:
parent
3522a015f6
commit
bab2db51e5
2 changed files with 15 additions and 7 deletions
|
@ -7,13 +7,13 @@ namespace FramedAnimator {
|
|||
public class Animator : MonoBehaviour {
|
||||
[SerializeField] private new Animation animation;
|
||||
public string CurrentAnimation => animation.name;
|
||||
private SpriteRenderer _renderer;
|
||||
public SpriteRenderer Renderer { get; private set; }
|
||||
|
||||
public event Action<string> OnAnimationEnd;
|
||||
private AnimatorModel _model;
|
||||
|
||||
private void Awake() {
|
||||
_renderer = GetComponent<SpriteRenderer>();
|
||||
Renderer = GetComponent<SpriteRenderer>();
|
||||
if(animation)
|
||||
_model = new AnimatorModel(animation.FrameRate, animation.FrameCount);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace FramedAnimator {
|
|||
|
||||
private void UpdateAnimationFrame() {
|
||||
_model.UpdateAnimationFrame(Time.deltaTime);
|
||||
_renderer.sprite = animation.GetFrame(_model.RenderingFrame);
|
||||
Renderer.sprite = animation.GetFrame(_model.RenderingFrame);
|
||||
}
|
||||
|
||||
private void TryCallAnimationEnd() {
|
||||
|
@ -41,7 +41,7 @@ namespace FramedAnimator {
|
|||
public void ChangeAnimation(Animation anim) {
|
||||
_model = new AnimatorModel(anim.FrameRate, anim.FrameCount);
|
||||
animation = anim;
|
||||
_renderer.sprite = animation.GetFrame(0);
|
||||
Renderer.sprite = animation.GetFrame(0);
|
||||
}
|
||||
|
||||
public void PlayUntil(float fraction) {
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue