예제 #1
0
        /// <summary>
        /// 定时任务的Tick
        /// </summary>
        private void TimerTick()
        {
            for (int i = 0; i < m_nextFrameExecuteActionList.Count; ++i)
            {
                m_nextFrameExecuteActionList[i]();
            }
            m_nextFrameExecuteActionList.Clear();

            float deltaTime = GameRealTime.DeltaTime * Time.timeScale;

            for (int i = m_timerFuncs.Count - 1; i >= 0; --i)
            {
                TimeFunc timerFunc = m_timerFuncs[i];
                if (timerFunc.canPause && Pause)
                {
                    continue;
                }

                timerFunc.time -= deltaTime;
                if (timerFunc.time <= 0)
                {
                    this.m_nextFrameExecuteActionList.Add(timerFunc.handler);

                    if (timerFunc.loop)
                    {
                        timerFunc.Reset();
                    }
                    else
                    {
                        m_timerFuncs.RemoveAt(i);
                    }
                }
            }
        }
예제 #2
0
            /// <summary>
            /// 定时任务的Tick
            /// </summary>
            private void TimerTick()
            {
                float deltaTime = GameRealTime.DeltaTime * Time.timeScale;

                for (int i = m_timerFuncs.Count - 1; i >= 0; --i)
                {
                    TimeFunc timerFunc = m_timerFuncs[i];
                    if (timerFunc.canPause && Pause)
                    {
                        continue;
                    }

                    timerFunc.time -= deltaTime;
                    if (timerFunc.time <= 0)
                    {
                        m_executeActionList.Add(timerFunc.handler);

                        if (timerFunc.loop)
                        {
                            timerFunc.Reset();

                            if (!timerFunc.undead)
                            {
                                timerFunc.age -= deltaTime;

                                if (timerFunc.age <= 0)
                                {
                                    if (null != timerFunc.finish_handler)
                                    {
                                        timerFunc.finish_handler();
                                    }

                                    m_timerFuncs.RemoveAt(i);
                                }
                            }
                        }
                        else
                        {
                            m_timerFuncs.RemoveAt(i);
                        }
                    }
                }



                for (int i = 0; i < m_executeActionList.Count; ++i)
                {
                    m_executeActionList[i]();
                }

                m_executeActionList.Clear();
            }