示例#1
0
    public void OnUpdate(float deltaTime)
    {
        float fixTime = deltaTime / Time.timeScale;

        for (int i = 0; i < list.Count; i++)
        {
            TimerProc proc = list[i];
            proc.SubTime(deltaTime, fixTime);

            if (proc.time <= 0)
            {
                proc.Call();

                if (proc.loop > 0)
                {
                    --proc.loop;
                    proc.time += proc.duration;
                }

                if (proc.loop == 0)
                {
                    list.RemoveAt(i--);
                }
                else if (proc.loop < 0)
                {
                    proc.time += proc.duration;
                }
            }
        }
    }
示例#2
0
    public void OnUpdate(float deltaTime)
    {
        DealAddTimerProcs();
        DealDelTimerProcs();

        float fixTime = deltaTime / Time.timeScale;

        for (int i = 0; i < list.Count; i++)
        {
            TimerProc proc = list[i];
            if (!IsValid(proc))
            {
                continue;
            }
            proc.SubTime(deltaTime, fixTime);

            if (proc.time <= 0)
            {
                try
                {
                    proc.Call();
                }
                catch (Exception e)
                {
                    delList.Add(proc);
                    Debug.LogError("timer call exception: " + e.Message);
                    continue;
                }
                if (proc.loop > 0)
                {
                    --proc.loop;
                    proc.time += proc.duration;
                }

                if (proc.loop == 0)
                {
                    delList.Add(proc);
                }
                else if (proc.loop < 0)
                {
                    proc.time += proc.duration;
                }
            }
        }
    }
示例#3
0
        public void OnUpdate(float deltaTime)
        {
            //Debug.Log("OnUpdate   "+deltaTime.ToString());

            float fixTime = deltaTime / Time.timeScale;

            for (int i = 0; i < list.Count; i++)
            {
                TimerProc proc = list[i];
                proc.SubTime(deltaTime, fixTime);

                if (proc.time <= 0)
                {
                    try
                    {
                        proc.Call();
                    }
                    catch (Exception e)
                    {
                        list.RemoveAt(i);
                        //Debugger.threadStack = e.StackTrace;
                        Debugger.LogError("timer call exception: {0}", e.Message);
                        continue;
                    }


                    if (proc.loop > 0)
                    {
                        --proc.loop;
                        proc.time += proc.duration;
                    }

                    if (proc.loop == 0)
                    {
                        list.RemoveAt(i--);
                    }
                    else if (proc.loop < 0)
                    {
                        proc.time += proc.duration;
                    }
                }
            }
        }