Beispiel #1
0
        /// <summary>
        /// 添加定时触发器
        /// </summary>
        /// <param name="time">定时时长</param>
        /// <param name="flag">定时器标识符</param>
        /// <param name="loop">是否循环</param>
        /// <param name="ignorTimescale">是否忽略TimeScale</param>
        /// <returns></returns>
        public static ETimer AddTimer(float time, string flag = "", bool loop = false, bool ignorTimescale = true)
        {
            ETimer timer = new ETimer(time, flag, loop, ignorTimescale);

            timers.Add(timer);
            return(timer);
        }
Beispiel #2
0
 /// <summary>
 /// 当计数器计时进行中执行的事件链
 /// </summary>
 /// <param name="timer"></param>
 /// <param name="updateEvent"></param>
 /// <returns></returns>
 public static ETimer OnUpdated(this ETimer timer, Action <float> updateEvent)
 {
     if (null == timer)
     {
         return(null);
     }
     timer.AddEvent(updateEvent);
     return(timer);
 }
Beispiel #3
0
 /// <summary>
 /// 当计时器计数完成时执行的事件链
 /// </summary>
 /// <param name="timer"></param>
 /// <param name="completedEvent"></param>
 /// <returns></returns>
 public static ETimer OnCompleted(this ETimer timer, Action completedEvent)
 {
     if (null == timer)
     {
         return(null);
     }
     timer.AddEvent(completedEvent);
     return(timer);
 }
Beispiel #4
0
 /// <summary>
 /// 删除用户指定的计时触发器
 /// </summary>
 /// <param name="timer"></param>
 public static void DelTimer(ETimer timer)
 {
     if (Exist(timer))
     {
         timer.Stop();
     }
     else
     {
         if (showLog)
         {
             Debug.Log("【TimerTrigger(容错)】:此定时器已完成触发或无此定时器!");
         }
     }
 }
Beispiel #5
0
        /// <summary>
        /// 删除用户指定的计时触发器
        /// </summary>
        /// <param name="updateEvent">指定的Update事件(直接赋值匿名函数无效)</param>
        public static void DelTimer(Action <float> updateEvent)
        {
            ETimer timer = timers.Find((v) => { return(v.UpdateEvent == updateEvent); });

            if (null != timer)
            {
                timer.Stop();
            }
            else
            {
                if (showLog)
                {
                    Debug.Log("【TimerTrigger(容错)】:定时器已完成触发或无此定时器!---方法名:【" + updateEvent.Method.Name + "】。");
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// 删除用户指定的计时触发器
        /// </summary>
        /// <param name="flag">指定的标识符</param>
        public static void DelTimer(string flag)
        {
            ETimer timer = GetTimer(flag);

            if (null != timer)
            {
                timer.Stop();
            }
            else
            {
                if (showLog)
                {
                    Debug.Log("【TimerTrigger(容错)】:此定时器已完成触发或无此定时器!");
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// 恢复用户指定的计时触发器
        /// </summary>
        /// <param name="flag"></param>
        public static void Resum(string flag)
        {
            ETimer timer = GetTimer(flag);

            if (null != timer)
            {
                timer.Resum();
            }
            else
            {
                if (showLog)
                {
                    Debug.Log("【TimerTrigger(容错)】:定时器已完成触发或无此定时器!---Flag【" + flag + "】。");
                }
            }
        }
Beispiel #8
0
 public ETimer OnUpdated(ETimer timer, Action <float> updateEvent)
 {
     return(TimerExtend.OnUpdated(timer, updateEvent));
 }
Beispiel #9
0
 public ETimer OnCompleted(ETimer timer, Action completedEvent)
 {
     return(TimerExtend.OnCompleted(timer, completedEvent));
 }
Beispiel #10
0
 public void Update()
 {
     ETimer.UpdateAllTimer();
 }
Beispiel #11
0
 /// <summary>
 /// 确认是否存在指定的定时器
 /// </summary>
 /// <param name="timer">定时器指定</param>
 /// <returns></returns>
 public static bool Exist(ETimer timer)
 {
     return(timers.Contains(timer));
 }