81 lines
2.2 KiB
C#
81 lines
2.2 KiB
C#
using BlueWater.Audios;
|
|
using BlueWater.Interfaces;
|
|
using BlueWater.Players;
|
|
using BlueWater.Utility;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine;
|
|
|
|
namespace BlueWater.Enemies.Bosses.SandMole
|
|
{
|
|
public class SandMoleStatus : MonoBehaviour, IStunnable
|
|
{
|
|
// Variables
|
|
#region Variables
|
|
|
|
[SerializeField]
|
|
private SpineController _spineController;
|
|
|
|
// Stun
|
|
[Title("기절 효과")]
|
|
[SerializeField]
|
|
private ParticleSystem _stunParticle;
|
|
|
|
public bool IsStunEnabled { get; private set; } = true;
|
|
public bool IsStunned { get; private set; }
|
|
|
|
private Coroutine _stunCoolDownCoroutine;
|
|
|
|
#endregion
|
|
|
|
private void Awake()
|
|
{
|
|
InitializeComponents();
|
|
}
|
|
|
|
[Button("컴포넌트 초기화")]
|
|
private void InitializeComponents()
|
|
{
|
|
_spineController = GetComponent<SpineController>();
|
|
}
|
|
|
|
// Stun
|
|
public bool CanStun() => IsStunEnabled;
|
|
|
|
public void Stun(float duration)
|
|
{
|
|
AudioManager.Instance.PlaySfx("SandMoleStunned");
|
|
_spineController.SetSkin(SandMoleSkin.Normal.ToString());
|
|
_spineController.PlayAnimation(SandMoleAnimation.Stun.ToString(), false);
|
|
IsStunned = true;
|
|
if (_stunParticle)
|
|
{
|
|
_stunParticle.Play();
|
|
}
|
|
|
|
Utils.StartUniqueCoroutine(this, ref _stunCoolDownCoroutine, Utils.CoolDownCoroutine(duration, EndStun));
|
|
}
|
|
|
|
public void TryStun(float duration)
|
|
{
|
|
if (!CanStun()) return;
|
|
|
|
Stun(duration);
|
|
}
|
|
|
|
public void EndStun()
|
|
{
|
|
_spineController.SetSkin(SandMoleSkin.Normal.ToString());
|
|
_spineController.PlayAnimation(SandMoleAnimation.Idle.ToString(), false);
|
|
|
|
Utils.EndUniqueCoroutine(this, ref _stunCoolDownCoroutine);
|
|
_stunParticle.Stop();
|
|
_stunParticle.Clear();
|
|
IsStunned = false;
|
|
}
|
|
|
|
public void StopAllCoroutine()
|
|
{
|
|
StopAllCoroutines();
|
|
}
|
|
}
|
|
} |