yyl
18 小时以前 5d3366f2e0f687995eb7ad2107c4379fe7acd4e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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;
            }
        }
    }
}