CapersProject/Assets/02.Scripts/Prop/SpineDamageableProps.cs
Nam Tae Gun a5c3159335 버그 및 수정
+ SpineDamageableProps Idle이 반복하지 않는 현상 수정
+ 플레이어 체력이 부족할 때, Vignette 효과 줄이고, 쉽게 수정할 수 있게 변경
+ 보스 처치 후 일정시간 무적 효과 적용
+ MiniSandMole 죽지 않는 버그 수정
+ Bgm 3종 추가 및 BgmSo 수정
2024-06-24 18:54:47 +09:00

65 lines
1.7 KiB
C#

using System.Collections;
using BlueWater.Audios;
using BlueWater.Players;
using BlueWater.Utility;
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 Coroutine _touchCoroutineInstance;
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;
Utils.StartUniqueCoroutine(this, ref _touchCoroutineInstance, TouchCoroutine());
}
private IEnumerator TouchCoroutine()
{
var touchTrack = _spineController.PlayAnimation(_touchAnimationName, false);
while (!touchTrack.IsComplete)
{
if (CurrentHealthPoint == 0) yield break;
yield return null;
}
_spineController.PlayAnimation(_idleAnimationName, true);
}
public override void Die()
{
if (!string.IsNullOrEmpty(DieSfxName))
{
AudioManager.Instance.PlaySfx(DieSfxName);
}
_spineController.PlayAnimation(_dieAnimationName, false);
}
}
}