Esempio n. 1
0
    public void Start()
    {
        if (!GetTimers.ContainsKey(this.UniqueName))
        {
            GetTimers.Add(this.UniqueName, this);
        }

        _fCreationTime  = (float)Time.time;
        _fNextIteration = _fCreationTime + Delay;
    }
Esempio n. 2
0
    public static void Clear()
    {
        foreach (util_timer timer in GetTimers.Values.ToList())
        {
            if (timer != null)
            {
                timer.Stop();
            }
        }

        GetTimers.Clear();
    }
Esempio n. 3
0
    public static util_timer Create(int reps, float delay, Action func, string uniqueName = "") {
        if (String.IsNullOrEmpty(uniqueName)) {
            uniqueName = MxTimer.ToString();
            MxTimer++;
        }

        var t = new util_timer { Iterations = reps, Delay = delay, Func = func, UniqueName = uniqueName };

        // Check if timer already exists
        if (GetTimers.ContainsKey(uniqueName))
            if (GetTimers[uniqueName] != null)
                t = GetTimers[uniqueName];

        t.Start();
        return t;
    }
Esempio n. 4
0
 public void Stop() {
     if (GetTimers.ContainsKey(this.UniqueName))
         GetTimers.Remove(this.UniqueName);
 }