Beispiel #1
0
 public void Register(string key, TimeHandler value)
 {
     if (handlers.ContainsKey(key))
     {
         handlers[key].Register(value.action);
     }
     else
     {
         handlers.Add(key, value);
     }
 }
Beispiel #2
0
        private void Update()
        {
            #region Handler
            eunmer = handlers.GetEnumerator();

            while (eunmer.MoveNext())
            {
                handler = eunmer.Current.Value;

                if (Time.time >= handler.timer)
                {
                    handler.Invoke();

                    if (handler.loop)
                    {
                        handler.timer = Time.time + handler.interval;
                    }
                    else
                    {
                        cache.Add(eunmer.Current.Key);
                    }
                }
            }

            count = cache.Count;

            if (count > 0)
            {
                for (int i = count - 1; i > -1; i--)
                {
                    if (handlers.ContainsKey(cache[i]))
                    {
                        handlers.Remove(cache[i]);
                    }
                    cache.RemoveAt(i);
                }
            }
            #endregion

            #region Duration
            Duration += (long)Time.deltaTime;
            #endregion
        }