Example #1
0
    public ACTimer CreateTimer(float waitTime, float timeInterval)
    {
        ACTimer timer = _GetUnusedTimer();

        timer.timeId       = _timerIndex;
        timer.runTimes     = 0;
        timer.startTime    = 0;
        timer.waitTime     = waitTime;
        timer.timeInterval = timeInterval;

        _timerIndex++;
        return(timer);
    }
Example #2
0
    private ACTimer _GetUnusedTimer()
    {
        ACTimer timer;

        if (_unusedTimers.Count > 0)
        {
            timer = _unusedTimers.Dequeue();
        }
        else
        {
            timer = new ACTimer();
        }
        return(timer);
    }
Example #3
0
 public void StopTimer(ACTimer timer)
 {
     _timer.Remove(timer);
     _unusedTimers.Enqueue(timer);
 }
Example #4
0
 public void StartTimer(ACTimer timer, System.Action onTimeup)
 {
     timer.startTime = Time.time;
     timer.onTimeup  = onTimeup;
     _timer.Add(timer);
 }