using System.Collections; using System.Collections.Generic; using UnityEngine; public class SnowFlake : MonoBehaviour { [SerializeField] protected Animator _animator; public SnowFlakeBehaviour _snowFlakeBehaviour; protected const string End = "End"; public bool IsPlay { get; private set; } protected void Awake() { _animator = GetComponent(); } // Update is called once per frame protected void Update() { if(IsPlay) { CheckPlayEnd(); } } public virtual void CheckPlayEnd() { if (_animator.GetCurrentAnimatorStateInfo(0).IsName(End)) { Reset(); } } public virtual void Play() { _animator.SetTrigger("Play"); _animator.SetBool("Play",true); IsPlay = true; } public virtual void Trigger() { if (_animator.GetCurrentAnimatorStateInfo(0).normalizedTime < 1) return; _animator.SetBool("Play", false); _animator.SetTrigger("Trigger"); } public virtual void Reset() { _animator.SetBool("Play", false); _animator.SetTrigger("Reset"); _snowFlakeBehaviour.ResetFlake(); IsPlay = false; } }