CapersProject/Assets/02.Scripts/Prop/SpineDamageableProps.cs

56 lines
1.5 KiB
C#
Raw Normal View History

using BlueWater.Audios;
using BlueWater.Players;
using UnityEngine;
namespace BlueWater
{
public class SpineDamageableProps : DamageableProps
{
[SerializeField]
private SpineController _spineController;
[SerializeField]
private string _idleAnimationName;
[SerializeField]
private string _touchAnimationName;
[SerializeField]
private string _dieAnimationName;
private void Awake()
{
_spineController = GetComponent<SpineController>();
}
protected override void OnEnable()
{
base.OnEnable();
_spineController.PlayAnimation(_idleAnimationName, true);
}
private void OnTriggerEnter(Collider other)
{
if (!other.CompareTag("Player") || CurrentHealthPoint <= 0) return;
_spineController.PlayAnimation(_touchAnimationName, false);
}
private void OnTriggerExit(Collider other)
{
if (!other.CompareTag("Player") || CurrentHealthPoint <= 0) return;
_spineController.PlayAnimation(_idleAnimationName, true);
}
public override void Die()
{
if (!string.IsNullOrEmpty(DieSfxName))
{
AudioManager.Instance.PlaySfx(DieSfxName);
}
_spineController.PlayAnimation(_dieAnimationName, false);
}
}
}