33 lines
623 B
C#
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();
|
|
}
|
|
}
|