Exemplo n.º 1
0
 public void QueueOperation(DelayedOperation newOperation)
 {
     _operations.Enqueue(newOperation);
     if (_operations.Count == 1)
     {
         StartTimer();
     }
 }
Exemplo n.º 2
0
        public void DequeueAllOperations()
        {
            foreach (DelayedOperation operation in _operations)
            {
                operation?.OnOperationCancelled();
            }

            _operations.Clear();
            if (_currentOperation != null)
            {
                _timer            = 0f;
                _currentOperation = null;
            }
        }
Exemplo n.º 3
0
 private void Update()
 {
     if (_currentOperation != null)
     {
         _timer -= Time.deltaTime;
         _currentOperation.OnTimerTick(/*1f - */ _timer / _currentOperation.Delay);
         if (_timer <= 0f)
         {
             _currentOperation.OnOperationComplete?.Invoke();
             _operations.Dequeue();
             if (_operations.Count > 0)
             {
                 _currentOperation = _operations.Peek();
                 _timer            = _currentOperation.Delay;
             }
             else
             {
                 _currentOperation = null;
                 _timer            = 0f;
             }
         }
     }
 }
Exemplo n.º 4
0
 private void StartTimer()
 {
     _currentOperation = _operations.Peek();
     _timer            = _currentOperation.Delay;
 }