Exemplo n.º 1
0
 public void Rewind()
 {
     _instructionPassedInMs   = 0;
     _callBegin               = true;
     _currentInstructionIndex = 0;
     _totalPassedInMs         = 0;
     TotalPassedPartChanged?.Invoke(this, EventArgs.Empty);
     Context.Scene.CloseMessageWindow();
 }
Exemplo n.º 2
0
        public void Update(int passedMs)
        {
            if (_instructions == null || _instructions.Length == 0 || _totalPassedInMs >= _totalDurationInMs)
            {
                return;
            }

            _instructionPassedInMs += passedMs;
            _totalPassedInMs       += passedMs;

            if (_totalPassedInMs > _totalDurationInMs)
            {
                _totalPassedInMs = _totalDurationInMs;
            }

            TotalPassedPartChanged?.Invoke(this, EventArgs.Empty);

            for (; _currentInstructionIndex < _instructions.Length; ++_currentInstructionIndex)
            {
                var instruction = _instructions[_currentInstructionIndex];

                var asQueue = instruction as QueueWorkItem;
                if (asQueue != null && asQueue.BlockDurationInMs <= _instructionPassedInMs)
                {
                    // Execute the whole queue right now if it is possible
                    foreach (var ins in asQueue.Block)
                    {
                        ins.Begin(this);
                        ins.End(this);
                    }
                    _callBegin = true;
                    continue;
                }

                if (_callBegin)
                {
                    instruction.Begin(this);
                    _callBegin = false;
                }

                if (_instructionPassedInMs < instruction.DurationInMs)
                {
                    instruction.Update(this);
                    break;
                }

                instruction.End(this);
                _callBegin = true;

                _instructionPassedInMs -= instruction.DurationInMs;
            }
        }