Pacman/Assets/Scripts/Ghost_behaviour.cs
2025-04-20 21:10:16 +05:30

33 lines
623 B
C#

using UnityEngine;
[RequireComponent(typeof(Ghost))]
public abstract class Ghost_behaviour : MonoBehaviour
{
public Ghost ghost { get; private set;}
public float duration;
private void Awake()
{
this.ghost = GetComponent<Ghost>();
this.enabled = false;
}
public void Enable()
{
Enable(this.duration);
}
public virtual void Enable (float duration)
{
this.enabled = true;
CancelInvoke();
Invoke(nameof(Disable), duration);
}
public virtual void Disable()
{
this.enabled = false;
CancelInvoke();
}
}