using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Timer : MonoBehaviour
{
private float timer;
private Action action;
private bool timeIsDone;
private void Update()
{
if (timer > 0 && !timeIsDone)
{
timer -= Time.deltaTime;
if (timer <= 0)
{
action?.Invoke();
timeIsDone = true;
ManagersMode.Poll.UnSpwan("Timer","timer",this.gameObject);
}
}
}
///
/// 创建计时器
///
/// 计时时间
/// 回调函数
public void CreateTime(float timer,Action cllBackAction, bool timeIsDone = false)
{
this.timer = timer;
this.action = cllBackAction;
this.timeIsDone = timeIsDone;
}
}