using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
|
public class TimeItem
|
{
|
|
public float time = 0.0f;
|
|
public Action<Component> func;
|
|
private Component m_Comp;
|
|
private int loopCnt = 0;
|
|
private int m_NowCnt = 0;
|
|
private float m_NowTime = 0.0f;
|
|
public TimeItem(float t, Component comp, int loopCnt, Action<Component> func)
|
{
|
time = t;
|
m_Comp = comp;
|
this.loopCnt = loopCnt;
|
this.func = func;
|
}
|
|
public void Update()
|
{
|
m_NowTime += Time.deltaTime;
|
if (m_NowTime >= time)
|
{
|
if (loopCnt != 0)
|
{
|
m_NowCnt++;
|
}
|
if (m_NowCnt >= loopCnt && loopCnt != 0)
|
{
|
m_NowCnt = 0;
|
m_NowTime = 0.0f;
|
TimeMgr.Instance.UnRegister(m_Comp);
|
func(m_Comp);
|
}
|
else
|
{
|
func(m_Comp);
|
m_NowTime = 0.0f;
|
}
|
}
|
}
|
}
|