You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.4 KiB

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";
protected const string Spwan = "Snowflake_Spawn";
public bool IsPlay { get; private set; }
protected void Awake()
{
_animator = GetComponent<Animator>();
}
// 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).IsName(Spwan) == false)
return;
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;
}
}