コード例 #1
0
ファイル: Timer.cs プロジェクト: yuanlipeng/LearnClinet
    // Start is called before the first frame update

    public void AddTimer(string key, Action cb, float interval, bool isReapet)
    {
        TimerCb time = new TimerCb();

        time.BeginTime = curWaitTime;
        time.Interval  = interval;
        time.Cb        = cb;
        time.IsReapet  = isReapet;

        mTimerCb[key] = time;
    }
コード例 #2
0
ファイル: Timer.cs プロジェクト: yuanlipeng/LearnClinet
    // Update is called once per frame
    public void Update()
    {
        if (mTimerCb.Count == 0)
        {
            return;
        }
        curWaitTime = curWaitTime + Time.deltaTime * Time.timeScale;

        List <string> needRemoveList = new List <string>();
        List <string> keys           = new List <string>(mTimerCb.Keys);

        for (int i = 0; i < keys.Count; i++)
        {
            if (mTimerCb.ContainsKey(keys[i]) == true)
            {
                TimerCb time = mTimerCb[keys[i]];
                if (time.BeginTime + time.Interval <= curWaitTime)
                {
                    time.Cb();

                    if (time.IsReapet == false)
                    {
                        needRemoveList.Insert(0, keys[i]);
                    }
                    else
                    {
                        time.BeginTime = curWaitTime;
                    }
                }
            }
        }

        for (int i = 0; i < needRemoveList.Count; i++)
        {
            mTimerCb.Remove(needRemoveList[i]);
        }
    }
コード例 #3
0
 extern public static int uv_timer_start(IntPtr handle, TimerCb cb, ulong timeout, ulong repeat);