28 lines
540 B
C#
28 lines
540 B
C#
using System;
|
|
using System.Collections;
|
|
using UnityEngine;
|
|
|
|
public class Timer
|
|
{
|
|
public delegate void OnEndDelegate();
|
|
|
|
public float RemainTimeSec;
|
|
|
|
public bool IsEnd { get; protected set; }
|
|
|
|
public event OnEndDelegate onEndEvent;
|
|
|
|
public Timer(float time, OnEndDelegate onEndEvent)
|
|
{
|
|
RemainTimeSec = time;
|
|
this.onEndEvent = onEndEvent;
|
|
IsEnd = false;
|
|
}
|
|
|
|
public static IEnumerator DelayMethod(float waitTime, Action process)
|
|
{
|
|
yield return new WaitForSeconds(waitTime);
|
|
process?.Invoke();
|
|
}
|
|
}
|